Using EB Tresos-generated RTD drivers with FreeRTOS + MPU

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using EB Tresos-generated RTD drivers with FreeRTOS + MPU

Jump to solution
136 Views
PhilippH
Contributor III

Hello,

we use the RTD 6.0.0 and BMS 0.9.1. SDK in EB Tresos to generate our driver code. It runs fine under FreeRTOS with Cortex M7 port that does not use the MPU.

Now, we want to switch to a FreeRTOS port that does use the MPU. I want to do this in two steps:

1) Making all tasks privileged but using the MPU, i.e. the MPU is reprogrammed in each context switch

2) Making all tasks unprivileged. That means I have to enable "Enable user mode support" in the drivers that are used by unprivileged tasks

Right now, I struggle at 1). Driver functions do not work reliably. For example, SPI only works intermittently. It seems as MPU regions are not working correctly. Even if this is resolved, how could 2) be implemented? The supervisor call handler is given by FreeRTOS and the RTD. Am I supposed to merge them?

Tags (3)
0 Kudos
Reply
1 Solution
55 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hello @PhilippH,

- Can I use the generic FreeRTOS, provided with correct M7+MPU Port?

You can use the generic FreeRTOS port; however, you will need to implement your own solution for S32K3-specific configuration, which is mostly provided in the NXP FreeRTOS package already. Please try to start with this port to see if it solves the problem.

- If not, is there an NXP-provided FreeRTOS that can be configured in EB Tresos?

No, the provided NXP package is compatible only with S32DS for now. Could you share why do you need FreeRTOS with EB Tresos?

Usually, EB Tresos is used for AUTOSAR compliant applications, however, the FreeRTOS package we provided is just for customer evaluation, not recommended to be used in production since it does not meet automotive certifications (ISO26262). You can see it is released as Code Drop (CD) Quality, this is because FreeRTOS is an open-source software and NXP provides it as a reference software without any safety certification.

If your application requires a safety-certified OS, you can explore other options, even from our partners:

It is up to the customer to select the appropriate third-party RTOS, stacks, IDEs, compilers, etc. for their project.

Best regards,
Julián

View solution in original post

4 Replies
99 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hello @PhilippH,

Firstly, MPU initial support was added in FreeRTOS 7.0.0 CD1, can you confirm this is the package you are using? (or 0.8.0 CD1, which is the latest release). 

1) Can you share which MPU regions are not working correctly? If possible, please share configuration and routine. 

Also, please follow the recommendations included inside the S32K3 FreeRTOS User Manual:

  • Enable Use mpu and Use mpu wrappers v1 options.
  • Set first configurable region to 9 instead of 0 to avoid conflict with MPU region from RTD.

Note: Integrating FreeRTOS with MPU support requires modifications in the RTD linker file to define the required memory sections used by FreeRTOS. Use the example files as reference when applying changes to your application.

2) I believe merging is not required, as FreeRTOSConfig.h declares the following macros:

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
#define vPortSVCHandler                             SVC_Handler
#define xPortPendSVHandler                          PendSV_Handler
#define xPortSysTickHandler                         SysTick_Handler

This redirects FreeRTOS's SVC calls to the RTD-provided SVC_Handler in exceptions.c.

Best regards,
Julián

 

0 Kudos
Reply
85 Views
PhilippH
Contributor III

Hello @Julián_AragónM,
I downloaded FreeRTOS from their website and used a port that supports both Cortex M7 and the MPU. If I understand you correctly, I need to use the NXP-provided FreeRTOS. I only found FreeRTOS by NXP that can be configured in S32DS, not EB Tresos. My questions are as follows:
- Can I use the generic FreeRTOS, provided with correct M7+MPU Port?
- If not, is there an NXP-provided FreeRTOS that can be configured in EB Tresos?

We need to use an ASIL-D certified OS at some point. If the NXP-provided FreeRTOS is not ASIL-D certified, we need to switch to something else.

0 Kudos
Reply
56 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hello @PhilippH,

- Can I use the generic FreeRTOS, provided with correct M7+MPU Port?

You can use the generic FreeRTOS port; however, you will need to implement your own solution for S32K3-specific configuration, which is mostly provided in the NXP FreeRTOS package already. Please try to start with this port to see if it solves the problem.

- If not, is there an NXP-provided FreeRTOS that can be configured in EB Tresos?

No, the provided NXP package is compatible only with S32DS for now. Could you share why do you need FreeRTOS with EB Tresos?

Usually, EB Tresos is used for AUTOSAR compliant applications, however, the FreeRTOS package we provided is just for customer evaluation, not recommended to be used in production since it does not meet automotive certifications (ISO26262). You can see it is released as Code Drop (CD) Quality, this is because FreeRTOS is an open-source software and NXP provides it as a reference software without any safety certification.

If your application requires a safety-certified OS, you can explore other options, even from our partners:

It is up to the customer to select the appropriate third-party RTOS, stacks, IDEs, compilers, etc. for their project.

Best regards,
Julián

43 Views
PhilippH
Contributor III

Thanks a lot for the answer.

I got it working with the NXP-provided SafeRTOS and Port as the NXP-provided port already solved the problems I had with the generic Cortex M7 + MPU port provided by SafeRTOS.

Regarding our need for EB Tresos: We started with S32DS, but due to the ICs we use, we needed a recent version of the BMS SDK, which was not available in S32DS (at least at the time). We want to do Autosar as little as possible. What worked for now was to generate the driver functions and calling them from FreeRTOS. We do not use and do not plan to use the Autosar RTE.


Regarding the 3rd party OS's: Does "With simple migration" mean that an equally user-friendly port exist for SafeRTOS? We used SafeRTOS before, but not with Autosar drivers, but purely handwritten drivers.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2413395%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EUsing%20EB%20Tresos-generated%20RTD%20drivers%20with%20FreeRTOS%20%2B%20MPU%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2413395%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3Ewe%20use%20the%20RTD%206.0.0%20and%20BMS%200.9.1.%20SDK%20in%20EB%20Tresos%20to%20generate%20our%20driver%20code.%20It%20runs%20fine%20under%20FreeRTOS%20with%20Cortex%20M7%20port%20that%20does%20not%20use%20the%20MPU.%3C%2FP%3E%3CP%3ENow%2C%20we%20want%20to%20switch%20to%20a%20FreeRTOS%20port%20that%20does%20use%20the%20MPU.%20I%20want%20to%20do%20this%20in%20two%20steps%3A%3C%2FP%3E%3CP%3E1)%20Making%20all%20tasks%20privileged%20but%20using%20the%20MPU%2C%20i.e.%20the%20MPU%20is%20reprogrammed%20in%20each%20context%20switch%3C%2FP%3E%3CP%3E2)%20Making%20all%20tasks%20unprivileged.%20That%20means%20I%20have%20to%20enable%20%22Enable%20user%20mode%20support%22%20in%20the%20drivers%20that%20are%20used%20by%20unprivileged%20tasks%3C%2FP%3E%3CP%3ERight%20now%2C%20I%20struggle%20at%201).%20Driver%20functions%20do%20not%20work%20reliably.%20For%20example%2C%20SPI%20only%20works%20intermittently.%20It%20seems%20as%20MPU%20regions%20are%20not%20working%20correctly.%20Even%20if%20this%20is%20resolved%2C%20how%20could%202)%20be%20implemented%3F%20The%20supervisor%20call%20handler%20is%20given%20by%20FreeRTOS%20and%20the%20RTD.%20Am%20I%20supposed%20to%20merge%20them%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2413634%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%20translate%3D%22no%22%3ERe%3A%20Using%20EB%20Tresos-generated%20RTD%20drivers%20with%20FreeRTOS%20%2B%20MPU%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2413634%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CP%3EHello%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F200831%22%20target%3D%22_blank%22%3E%40Juli%C3%A1n_Arag%C3%B3nM%3C%2FA%3E%2C%3CBR%20%2F%3EI%20downloaded%20FreeRTOS%20from%20their%20website%20and%20used%20a%20port%20that%20supports%20both%20Cortex%20M7%20and%20the%20MPU.%20If%20I%20understand%20you%20correctly%2C%20I%20need%20to%20use%20the%20NXP-provided%20FreeRTOS.%20I%20only%20found%20FreeRTOS%20by%20NXP%20that%20can%20be%20configured%20in%20S32DS%2C%20not%20EB%20Tresos.%20My%20questions%20are%20as%20follows%3A%3CBR%20%2F%3E-%20Can%20I%20use%20the%20generic%20FreeRTOS%2C%20provided%20with%20correct%20M7%2BMPU%20Port%3F%3CBR%20%2F%3E-%20If%20not%2C%20is%20there%20an%20NXP-provided%20FreeRTOS%20that%20can%20be%20configured%20in%20EB%20Tresos%3F%3C%2FP%3E%3CP%3EWe%20need%20to%20use%20an%20ASIL-D%20certified%20OS%20at%20some%20point.%20If%20the%20NXP-provided%20FreeRTOS%20is%20not%20ASIL-D%20certified%2C%20we%20need%20to%20switch%20to%20something%20else.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2413487%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Using%20EB%20Tresos-generated%20RTD%20drivers%20with%20FreeRTOS%20%2B%20MPU%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2413487%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F254882%22%20target%3D%22_blank%22%3E%40PhilippH%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EFirstly%2C%20MPU%20initial%20support%20was%20added%20in%20FreeRTOS%207.0.0%20CD1%2C%20can%20you%20confirm%20this%20is%20the%20package%20you%20are%20using%3F%20(or%200.8.0%20CD1%2C%20which%20is%20the%20latest%20release).%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1)%20Can%20you%20share%20which%20MPU%20regions%20are%20not%20working%20correctly%3F%20If%20possible%2C%20please%20share%20configuration%20and%20routine.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlso%2C%20please%20follow%20the%20recommendations%20included%20inside%20the%20S32K3%20FreeRTOS%20User%20Manual%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EEnable%20Use%20mpu%20and%20Use%20mpu%20wrappers%20v1%20options.%3C%2FLI%3E%0A%3CLI%3ESet%20first%20configurable%20region%20to%209%20instead%20of%200%20to%20avoid%20conflict%20with%20MPU%20region%20from%20RTD.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3ENote%3A%3C%2FSTRONG%3E%20Integrating%20FreeRTOS%20with%20MPU%20support%20requires%20modifications%20in%20the%20RTD%20linker%20file%20to%20define%20the%20required%20memory%20sections%20used%20by%20FreeRTOS.%20Use%20the%20example%20files%20as%20reference%20when%20applying%20changes%20to%20your%20application.%3C%2FP%3E%0A%3CP%3E2)%20I%20believe%20merging%20is%20not%20required%2C%20as%20FreeRTOSConfig.h%20declares%20the%20following%20macros%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%2F*%20Definitions%20that%20map%20the%20FreeRTOS%20port%20interrupt%20handlers%20to%20their%20CMSIS%0Astandard%20names.%20*%2F%0A%23define%20vPortSVCHandler%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20SVC_Handler%0A%23define%20xPortPendSVHandler%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PendSV_Handler%0A%23define%20xPortSysTickHandler%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20SysTick_Handler%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThis%20redirects%20FreeRTOS's%20SVC%20calls%20to%20the%20RTD-provided%20SVC_Handler%20in%20exceptions.c.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2413783%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Using%20EB%20Tresos-generated%20RTD%20drivers%20with%20FreeRTOS%20%2B%20MPU%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2413783%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F254882%22%20target%3D%22_blank%22%3E%40PhilippH%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E-%20Can%20I%20use%20the%20generic%20FreeRTOS%2C%20provided%20with%20correct%20M7%2BMPU%20Port%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20the%20generic%20FreeRTOS%20port%3B%20however%2C%20you%20will%20need%20to%20implement%20your%20own%20solution%20for%20S32K3-specific%20configuration%2C%20which%20is%20mostly%20provided%20in%20the%20NXP%20FreeRTOS%20package%20already.%20Please%20try%20to%20start%20with%20this%20port%20to%20see%20if%20it%20solves%20the%20problem.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E-%20If%20not%2C%20is%20there%20an%20NXP-provided%20FreeRTOS%20that%20can%20be%20configured%20in%20EB%20Tresos%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ENo%2C%20the%20provided%20NXP%20package%20is%20compatible%20only%20with%20S32DS%20for%20now.%20Could%20you%20share%20why%20do%20you%20need%20FreeRTOS%20with%20EB%20Tresos%3F%3C%2FP%3E%0A%3CP%3EUsually%2C%20EB%20Tresos%20is%20used%20for%20AUTOSAR%20compliant%20applications%2C%20however%2C%20the%20FreeRTOS%20package%20we%20provided%20is%20just%20for%20customer%20evaluation%2C%20not%20recommended%20to%20be%20used%20in%20production%20since%20it%20does%20not%20meet%20automotive%20certifications%20(ISO26262).%20You%20can%20see%20it%20is%20released%20as%20Code%20Drop%20(CD)%20Quality%2C%20this%20is%20because%20FreeRTOS%20is%20an%20open-source%20software%20and%20NXP%20provides%20it%20as%20a%20reference%20software%20without%20any%20safety%20certification.%3C%2FP%3E%0A%3CP%3EIf%20your%20application%20requires%20a%20safety-certified%20OS%2C%20you%20can%20explore%20other%20options%2C%20even%20from%20our%20partners%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESafeRTOS%20(Based%20on%20the%20FreeRTOS%20functional%20model%2C%20with%20simple%20migration)%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.highintegritysystems.com%2Fsafertos%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.highintegritysystems.com%2Fsafertos%2F%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EAUTOSAR%20OS%3C%2FLI%3E%0A%3CLI%3E%C2%B5-velOSity%3C%2FLI%3E%0A%3CLI%3EembOS-Safe%3C%2FLI%3E%0A%3CLI%3ENXP%20RTOS%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIt%20is%20up%20to%20the%20customer%20to%20select%20the%20appropriate%20third-party%20RTOS%2C%20stacks%2C%20IDEs%2C%20compilers%2C%20etc.%20for%20their%20project.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FP%3E%3C%2FLINGO-BODY%3E