I get the error 'Changing property 'CustomSource' is not allowed ' when using the Simulink Coder

Hello!
I've tried to use a custom configuration for building processus for Simulink Emdedded coder to build a flashing file for my is ARM CortexTM-R4F 32-bit target.
The code I've used should just specify custom C file from Matlab script:
slbuild(MODEL_NAME);
configs = getActiveConfigSet(gcs);
configs.set_param('CustomSource', '\libs\src\calcCRC32.c', '\libs\src\sfunc_calcCRC32.c', '\libs\include\calcCRC32.h');
tic;
slbuild(MODEL_NAME);
I've tried to check the Model configurator but without succes.

2 commentaires

Can you try removing the first "slbuild(MODEL_NAME)" line? Or run the config.set_param() and then slbuild() one step at a time? I wonder if the error message merely means that you can not change the property while the Simulink Coder is running.
I've tried to remove the first slbuild(MODEL_NAME) but the Matlab does not detect the gcs in this case.
I've used this script as a base:
https://stackoverflow.com/questions/36059596/simulink-coder-how-to-specify-custom-c-files-from-script-when-generating-c-code

Connectez-vous pour commenter.

 Réponse acceptée

Thanks to @Fangjun Jiang the modified code is now running:
open(MODEL_NAME);
configs = getActiveConfigSet(MODEL_NAME);
configs.set_param('CustomSource', '\libs\src\calcCRC32.c');
save_system(MODEL_NAME);
tic;
close_system(MODEL_NAME);
tic;
slbuild(MODEL_NAME);

Plus de réponses (1)

Fangjun Jiang
Fangjun Jiang le 26 Fév 2026 à 15:49
Modifié(e) : Fangjun Jiang le 27 Fév 2026 à 16:02
I've run this on a simple example and it worked.
configs = getActiveConfigSet(MODEL_NAME);
configs.set_param('CustomSource', '\libs\src\calcCRC32.c');
slbuild(MODEL_NAME);

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Centre d'aide et File Exchange

Question posée :

le 26 Fév 2026 à 13:45

Réponse apportée :

le 3 Mar 2026 à 11:43

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by