Skip to content
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

[SKIP SOF-TEST] native loadable up-down-mixer take 2 #8210

Closed

Conversation

pjdobrowolski
Copy link
Contributor

This is second approach to native sof loadable modules. This time are used zephyr's linker scripts to create separate archive for modules and put them into specific for module sections. After that cmake files, using objcopy put code for up-down-mixer to udm.mod file which is being sign by rimage.

Full process of building module is automated and run by python building scripts:
xtensa-build-zephyr.py -u mtl -k ../keys/<used_key_for_project>

@pjdobrowolski pjdobrowolski changed the title Sof pawelxd loadable udm native loadable up-down-mixer take 2 Sep 18, 2023
@pjdobrowolski pjdobrowolski reopened this Sep 18, 2023
@pjdobrowolski pjdobrowolski marked this pull request as draft September 18, 2023 07:27
@@ -463,6 +495,3 @@ static struct module_interface up_down_mixer_interface = {
.reset = up_down_mixer_reset,
.free = up_down_mixer_free
};

DECLARE_MODULE_ADAPTER(up_down_mixer_interface, up_down_mixer_comp_uuid, up_down_mixer_comp_tr);
SOF_MODULE_INIT(up_down_mixer, sys_comp_module_up_down_mixer_interface_init);
Copy link
Contributor

@marcinszkudlinski marcinszkudlinski Sep 18, 2023

Choose a reason for hiding this comment

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

I think we need to have ability to use module in 2 ways - as a loadable OR as a built-in
It may be a kConfig option

quick suggestion (may be incorrect syntax, just a rough example):

choice
     prompt "up down mixer module"

config NO_UP_DOWN_MIXER
     bool "up down mixer not available"

config BUILT_IN_UP_DOWN_MIXER
     bool "up down mixer as a bullt in module"

config LOADABLE_IN_UP_DOWN_MIXER
     bool "up down mixer as a loadable module"
endchoice

Copy link
Member

Choose a reason for hiding this comment

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

Linux Kconfig uses a tristate variable for modules
y = builtin
n = not built
m = module
We shoudl do the same to simplify our Kconfigs.

@@ -497,30 +512,6 @@ zephyr_library_sources_ifdef(CONFIG_SAMPLE_KEYPHRASE
${SOF_SAMPLES_PATH}/audio/detect_test.c
)

if(CONFIG_IPC_MAJOR_3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Conversion of a specific module to loadable should be in separate commit than the loadable module infrastructure

.affinity_mask = 1,
}
};

Copy link
Contributor

Choose a reason for hiding this comment

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

DITTO

* \brief Type definition of the package entry point.
* \note internal purpose.
*/
typedef int (ModulePackageEntryPoint)(uint32_t costam);
Copy link
Contributor

Choose a reason for hiding this comment

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

english please ;)

DEFINE_MODULE_PACKAGE_ENTRY_POINT(MODULE)

/*
* #define DECLARE_LOADABLE_MODULE(MODULE, MODULE_FACTORY) \
Copy link
Contributor

Choose a reason for hiding this comment

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

why commeted out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

during development we decided to drop that header file.

struct sof_module_api_build_info udm_build_info __attribute__((section(".buildinfo"))) = {
ADSP_BUILD_INFO_FORMAT,
{
((0x3FF & 5) << 20) |
Copy link
Contributor

Choose a reason for hiding this comment

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

prepare a macro for those shifts

# Create Trace realtive file paths
sof_append_relative_path_definitions(modules_sof)


# Compile up_down_mixer as loadable module
sof_loadable_library(udm ${SOF_AUDIO_PATH}/up_down_mixer/up_down_mixer.toml)
Copy link
Contributor

Choose a reason for hiding this comment

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

more meaningful name (updwmix) instead of udm

}
};

extern struct module_interface up_down_mixer_interface;
Copy link
Contributor

Choose a reason for hiding this comment

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

this forward really needed? Maybe move declaration of sof_module_api_build_info to the end of the file?

.type = { .load_type = SOF_MAN_MOD_TYPE_MODULE,
.domain_ll = 1 },
.affinity_mask = 1,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

indent

@@ -8,7 +8,8 @@
#ifndef _LOADABLE_PROCESSING_MODULE_H_
#define _LOADABLE_PROCESSING_MODULE_H_

#include <sof/audio/module_adapter/iadk/adsp_stddef.h>
#include <sof/audio/module_adapter/iadk/adsp_stddef.h>
#include <sof/audio/module_adapter/library/module_api_ver.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesn't look right. You haven't changed anything in the header, so there's no reason why it now need that additional header

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

Thanks but I'm pretty sure the plan for /lib/firmare/intel/sof/ is to use --use-platform-subdir like this:

sof/scripts/xtensa-build-zephyr.py --use-platform-subdir mtl


build-sof-staging 
|-- sof 
|   +-- mtl 
|       |-- community 
|       |   +-- sof-mtl.ri 	sha256=401e8360bd1a...
|       |-- sof-mtl.ldc 	sha256=516ad1320ec8...
|       |-- loadable_module1.ri
|       |-- loadable_module2.ri

|       +-- loadable_module3.ri

EDIT: maybe --use-platform-subdir should be ON by default?

@plbossart
Copy link
Member

The 'base fw' and loadable modules can be signed with different keys, so we absolutely do not want them to land in the same directory - the loadable modules MUST be in a key-specific directory.

@marc-hb
Copy link
Collaborator

marc-hb commented Sep 18, 2023

@plbossart you're referring to --key-type-subdir.

I was talking about --use-platform-subdir which avoids the ugly sof-{file}-lib.ri rename hack.

They're not mutually exclusive.

In any case we need a tiny bit of plain english documentation to be reviewed and approved first, we don't want people to have to search and read python or kernel code[*] to try and fail to guess the /lib/firmware/intel/sof/ structure.

This can be as simple as 1-2 pages with the output of a sample "tree" command with a few plain English words around it. Let's stop making the same mistake over and over again:

[*] from @plbossart https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/intel/pci-mtl.c#L39

@pjdobrowolski
Copy link
Contributor Author

I appreciate your engagement but this is still a draft.

@marc-hb
Copy link
Collaborator

marc-hb commented Sep 20, 2023

In any case we need a tiny bit of plain english documentation to be reviewed and approved first, we don't want people to have to search and read python or kernel code[*] to try and fail to guess the /lib/firmware/intel/sof/ structure.

Thank you @kv2019i !

So according to that sof-docs PR, the path for loadable modules is: sof-ipc4-lib/PLAT/community/UUID.bin

Comment on lines 31 to 41
/*!
* \def STR(s)
* intermediate macro for Stringification
* \note internal purpose only. Consider to use XSTR(s) for Stringification.
*/
#define STR(s) #s
/*!
* \def XSTR(s)
* Stringification macro
*/
#define XSTR(s) STR(s)
Copy link
Member

Choose a reason for hiding this comment

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

need to be careful here as I would imagine these common macros should come from Zephyr.

* \note internal purpose.
*/
#define DEFINE_MODULE_PACKAGE_ENTRY_POINT(MODULE) \
volatile sof_module_api_build_info MODULE_PACKAGE_ENTRY_BUILD_INFO_NAME(MODULE) BUILD_INFO_SECTION = \
Copy link
Member

Choose a reason for hiding this comment

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

why does this need to be volatile ?

@@ -0,0 +1,86 @@
version = [3, 0]

[adsp]
Copy link
Member

Choose a reason for hiding this comment

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

fwiw, @aiChaoSONG is looking at having an #include <platform.toml> for all the non module stuff. This will help simplify

@@ -463,6 +495,3 @@ static struct module_interface up_down_mixer_interface = {
.reset = up_down_mixer_reset,
.free = up_down_mixer_free
};

DECLARE_MODULE_ADAPTER(up_down_mixer_interface, up_down_mixer_comp_uuid, up_down_mixer_comp_tr);
SOF_MODULE_INIT(up_down_mixer, sys_comp_module_up_down_mixer_interface_init);
Copy link
Member

Choose a reason for hiding this comment

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

Linux Kconfig uses a tristate variable for modules
y = builtin
n = not built
m = module
We shoudl do the same to simplify our Kconfigs.

softwarecki and others added 4 commits September 25, 2023 09:13
Added toml file to enable building up down mixer as loadable module.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Updated zephyr revision to the top of 006 branch

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
updated zephyr to mtl-006
updated rimage to mtl-006
@pjdobrowolski pjdobrowolski force-pushed the sof_pawelxd_loadable_udm branch 4 times, most recently from c662f6d to 58c0bdf Compare September 28, 2023 06:44
@marc-hb marc-hb changed the title native loadable up-down-mixer take 2 [SKIP SOF-TEST] native loadable up-down-mixer take 2 Sep 28, 2023
Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
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.

7 participants