[DEV] STM32L5xx support

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

[DEV] STM32L5xx support

Postby Giovanni » Thu Mar 26, 2020 7:33 pm

OK, first results with this one.

Code: Select all


*** ChibiOS/RT Test Suite
***
*** Compiled:     Mar 26 2020 - 19:24:40
*** Platform:     STM32L5 Ultra Low Power
*** Test Board:   STMicroelectronics STM32 Nucleo144-L552ZE
***
*** Text size:    36972 bytes
*** RO data size: 9840 bytes
*** Data size:    220 bytes
*** BSS size:     5056 bytes

============================================================================
=== Test Sequence 1 (Information)
----------------------------------------------------------------------------
--- Test Case 1.1 (Port Info)
--- Architecture:                       ARMv8-M Mainline
--- Core Variant:                       Cortex-M33
--- Compiler:                           GCC 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
--- Port Info:                          Advanced kernel mode
--- Natural alignment:                  4
--- Stack alignment:                    32
--- Working area alignment:             32
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (Kernel Info)
--- Product:                            ChibiOS/RT
--- Stable Flag:                        0
--- Version String:                     6.1.0
--- Major Number:                       6
--- Minor Number:                       1
--- Patch Number:                       0
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (Kernel Settings)
--- CH_CFG_ST_RESOLUTION:               32
--- CH_CFG_ST_FREQUENCY:                10000
--- CH_CFG_INTERVALS_SIZE:              32
--- CH_CFG_TIME_TYPES_SIZE:             32
--- CH_CFG_ST_TIMEDELTA:                2
--- CH_CFG_TIME_QUANTUM:                0
--- CH_CFG_MEMCORE_SIZE:                0
--- CH_CFG_NO_IDLE_THREAD:              0
--- CH_CFG_OPTIMIZE_SPEED:              1
--- CH_CFG_USE_TM:                      1
--- CH_CFG_USE_REGISTRY:                1
--- CH_CFG_USE_WAITEXIT:                1
--- CH_CFG_USE_SEMAPHORES:              1
--- CH_CFG_USE_SEMAPHORES_PRIORITY:     0
--- CH_CFG_USE_MUTEXES:                 1
--- CH_CFG_USE_MUTEXES_RECURSIVE:       0
--- CH_CFG_USE_CONDVARS:                1
--- CH_CFG_USE_CONDVARS_TIMEOUT:        1
--- CH_CFG_USE_EVENTS:                  1
--- CH_CFG_USE_EVENTS_TIMEOUT:          1
--- CH_CFG_USE_MESSAGES:                1
--- CH_CFG_USE_MESSAGES_PRIORITY:       0
--- CH_CFG_USE_DYNAMIC:                 1
--- CH_DBG_STATISTICS:                  0
--- CH_DBG_SYSTEM_STATE_CHECK:          0
--- CH_DBG_ENABLE_CHECKS:               0
--- CH_DBG_ENABLE_ASSERTS:              0
--- CH_DBG_TRACE_MASK:                  255
--- CH_DBG_TRACE_BUFFER_SIZE:           128
--- CH_DBG_ENABLE_STACK_CHECK:          0
--- CH_DBG_FILL_THREADS:                0
--- CH_DBG_THREADS_PROFILING:           0
--- Result: SUCCESS
============================================================================
=== Test Sequence 2 (System layer and port interface)
----------------------------------------------------------------------------
--- Test Case 2.1 (System integrity functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Critical zones functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Interrupts handling functionality)
--- Result: SUCCESS
============================================================================
=== Test Sequence 3 (Time and Intervals Functionality)
----------------------------------------------------------------------------
--- Test Case 3.1 (System Tick Counter functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Time ranges functionality)
--- Result: SUCCESS
============================================================================
=== Test Sequence 4 (Threads Functionality)
----------------------------------------------------------------------------
--- Test Case 4.1 (Thread Sleep functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.2 (Ready List functionality, threads priority order)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.3 (Priority change test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.4 (Priority change test with Priority Inheritance)
--- Result: SUCCESS
============================================================================
=== Test Sequence 5 (Suspend/Resume)
----------------------------------------------------------------------------
--- Test Case 5.1 (Suspend and Resume functionality)
--- Result: SUCCESS
============================================================================
=== Test Sequence 6 (Counter Semaphores)
----------------------------------------------------------------------------
--- Test Case 6.1 (Semaphore primitives, no state change)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.2 (Semaphore enqueuing test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.3 (Semaphore timeout test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.4 (Testing chSemAddCounterI() functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.5 (Testing chSemWaitSignal() functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.6 (Testing Binary Semaphores special case)
--- Result: SUCCESS
============================================================================
=== Test Sequence 7 (Mutexes, Condition Variables and Priority Inheritance)
----------------------------------------------------------------------------
--- Test Case 7.1 (Priority enqueuing test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.2 (Priority return verification)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.3 (Repeated locks, non recursive scenario)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.4 (Condition Variable signal test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.5 (Condition Variable broadcast test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.6 (Condition Variable priority boost test)
--- Result: SUCCESS
============================================================================
=== Test Sequence 8 (Synchronous Messages)
----------------------------------------------------------------------------
--- Test Case 8.1 (Messages Server loop)
--- Result: SUCCESS
============================================================================
=== Test Sequence 9 (Event Sources and Event Flags)
----------------------------------------------------------------------------
--- Test Case 9.1 (Events registration)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.2 (Event Flags dispatching)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.3 (Events Flags wait using chEvtWaitOne())
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.4 (Events Flags wait using chEvtWaitAny())
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.5 (Events Flags wait using chEvtWaitAll())
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.6 (Events Flags wait timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.7 (Broadcasting using chEvtBroadcast())
--- Result: SUCCESS
============================================================================
=== Test Sequence 10 (Dynamic threads)
----------------------------------------------------------------------------
--- Test Case 10.1 (Threads creation from Memory Heap)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.2 (Threads creation from Memory Pool)
--- Result: SUCCESS
============================================================================
=== Test Sequence 11 (Benchmarks)
----------------------------------------------------------------------------
--- Test Case 11.1 (Messages performance #1)
--- Score : 238072 msgs/S, 476144 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Messages performance #2)
--- Score : 181203 msgs/S, 362406 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Messages performance #3)
--- Score : 181204 msgs/S, 362408 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Context Switch performance)
--- Score : 808760 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Threads performance, full cycle)
--- Score : 137146 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Threads performance, create/exit only)
--- Score : 179724 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Mass reschedule performance)
--- Score : 56814 reschedules/S, 340884 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Round-Robin voluntary reschedule)
--- Score : 483460 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Virtual Timers set/reset performance)
--- Score : 442648 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Semaphores wait/signal performance)
--- Score : 1016076 wait+signal/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Mutexes lock/unlock performance)
--- Score : 590556 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (RAM Footprint)
--- System: 120 bytes
--- Thread: 68 bytes
--- Timer : 20 bytes
--- Semaph: 12 bytes
--- Mutex : 16 bytes
--- CondV.: 8 bytes
--- EventS: 4 bytes
--- EventL: 20 bytes
--- MailB.: 40 bytes
--- Result: SUCCESS
----------------------------------------------------------------------------

Final result: SUCCESS

*** ChibiOS OS Library Test Suite
***
*** Compiled:     Mar 26 2020 - 19:24:40
*** Platform:     STM32L5 Ultra Low Power
*** Test Board:   STMicroelectronics STM32 Nucleo144-L552ZE
***
*** Text size:    36972 bytes
*** RO data size: 9840 bytes
*** Data size:    220 bytes
*** BSS size:     5056 bytes

============================================================================
=== Test Sequence 1 (Information)
----------------------------------------------------------------------------
--- Test Case 1.1 (Port Info)
--- Architecture:                       ARMv8-M Mainline
--- Core Variant:                       Cortex-M33
--- Compiler:                           GCC 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
--- Port Info:                          Advanced kernel mode
--- Natural alignment:                  4
--- Stack alignment:                    32
--- Working area alignment:             32
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (OS Library Info)
--- Product:                            ChibiOS/LIB
--- Stable Flag:                        0
--- Version String:                     1.2.0
--- Major Number:                       1
--- Minor Number:                       2
--- Patch Number:                       0
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (OS Library Settings)
--- CH_CFG_USE_MAILBOXES:               1
--- CH_CFG_USE_MEMCORE:                 1
--- CH_CFG_USE_HEAP:                    1
--- CH_CFG_USE_MEMPOOLS:                1
--- CH_CFG_USE_OBJ_FIFOS:               1
--- CH_CFG_USE_PIPES:                   1
--- CH_CFG_USE_OBJ_CACHES:              1
--- CH_CFG_USE_DELEGATES:               1
--- CH_CFG_USE_FACTORY:                 1
--- CH_CFG_FACTORY_MAX_NAMES_LENGTH:    8
--- CH_CFG_FACTORY_OBJECTS_REGISTRY:    1
--- CH_CFG_FACTORY_GENERIC_BUFFERS:     1
--- CH_CFG_FACTORY_SEMAPHORES:          1
--- CH_CFG_FACTORY_MAILBOXES:           1
--- CH_CFG_FACTORY_OBJ_FIFOS:           1
--- CH_CFG_FACTORY_PIPES:               1
--- Result: SUCCESS
============================================================================
=== Test Sequence 2 (Mailboxes)
----------------------------------------------------------------------------
--- Test Case 2.1 (Mailbox normal API, non-blocking tests)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Mailbox I-Class API, non-blocking tests)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Mailbox timeouts)
--- Result: SUCCESS
============================================================================
=== Test Sequence 3 (Pipes)
----------------------------------------------------------------------------
--- Test Case 3.1 (Pipes normal API, non-blocking tests)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Pipe timeouts)
--- Result: SUCCESS
============================================================================
=== Test Sequence 4 (Jobs Queues)
----------------------------------------------------------------------------
--- Test Case 4.1 (Dispatcher test)
--- Result: SUCCESS
============================================================================
=== Test Sequence 5 (Thread Delegates)
----------------------------------------------------------------------------
--- Test Case 5.1 (Dispatcher test)
--- Result: SUCCESS
============================================================================
=== Test Sequence 6 (Objects Caches)
----------------------------------------------------------------------------
--- Test Case 6.1 (Cache initialization)
--- Result: SUCCESS
============================================================================
=== Test Sequence 7 (Memory Pools)
----------------------------------------------------------------------------
--- Test Case 7.1 (Loading and emptying a memory pool)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.2 (Loading and emptying a guarded memory pool without waiting)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.3 (Guarded Memory Pools timeout)
--- Result: SUCCESS
============================================================================
=== Test Sequence 8 (Memory Heaps)
----------------------------------------------------------------------------
--- Test Case 8.1 (Allocation and fragmentation)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 8.2 (Default Heap)
--- Result: SUCCESS
============================================================================
=== Test Sequence 9 (Objects Factory)
----------------------------------------------------------------------------
--- Test Case 9.1 (Objects Registry)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.2 (Dynamic Buffers Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.3 (Dynamic Semaphores Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.4 (Dynamic Mailboxes Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.5 (Dynamic Objects FIFOs Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.6 (Dynamic Pipes Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------

Final result: SUCCESS


There is still a lot to do:
- Lots of HAL drivers need overhaul or new versions in order to handle secure/nonsecure domains (peripherals need to be assigned to a domain in mcuconf.h).
- ARMv8-M port need to support new v8 features: new MPU, TZ/NS switch, stack protection registers (lot of fun here).
- Implement a dual RTOS demo, one running in secure domain, another running in NS domain into a thread of the 1st one.
- Implement some kind of secure bootloader so the NS application can be loaded /updated from secure world.
- Leverage L5 I-cache.

Probably I am forgetting other things, anyway, the demo works and is in TZ (TZEN=1).

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [DEV] STM32L5xx support

Postby Giovanni » Thu Apr 02, 2020 2:05 pm

News regarding support of STM32L5 and ARMv8-M in general.

Until now, the ARMCMx port performed the context switch in "process context", this allowed for higher peak context switch performance, this also worked for ARMv8-M and it is how the benchmark I posted were performed.

Now I am experimenting with switch in "exception context" which is what ARM seems to suggest, ChibiOS can support both modes equally well, it is just matter of port implementation choices.

With switch in exception mode SVC is used for thread-to-thread switching, PendSV is used in order to reschedule as IRQ tail exception (lowest priority). There are consequences:

  1. Thread-to-thread context switch is 30% slower (worst case, not very realistic) because SVC also saves the caller-saved registers, something that was not needed with the "process mode" switch code.
  2. On the other side, the IRQ epilogue code is much more efficient and the FPU lazy-save mechanism is better exploited, IRQ processing is in general improved, thread fly-back time should be improved too (to be measured).
  3. The "exception context" mode is able to handle the switch between Secure and Non-Secure worlds, something that the previous port cannot support.
  4. There is no more the limitation with ISRs without prologue/epilogue macros, you can have "naked IRQs" at any priority level. In the previous ports you must have all "haked IRQ" at priority above any RTOS IRQ.
  5. PendSV cannot be used by user code, is reserved. Any other SW-triggered IRQ can be used, NVIC allows to do that on any source.

I also tested the "stack limit" registers and I am very happy with that, it allows for very accurate stack overflow checking without much overhead (one more word in the thread context). MPU handling is no more required, no more wasted RAM with guard pages. This can work with both ports.

On the repository there are 2 demos, one using the old method, one using the new one. I am thinking to keep both ports but extra choices could generate confusion.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [DEV] STM32L5xx support

Postby Giovanni » Mon Apr 13, 2020 9:50 am

Hi,

Small update, milestone achieved....

Now there is non-secure code running as a thread under an RTOS running in TZ. Next step is making this small NS code become an application with its own RTOS and that would be an huge feature. There would be 2 RTOSes in the system, one dedicated to trusted tasks (the host) and another running a regular application (the guest). The new ARMv8-M port will support both host and guest modes, a "normal" mode is also supported if TZ is not used.

The guest application will be able to access trusted services via a dedicated API. Note that the secure application could also act as a secure bootloader for the non-secure application. Implementing some kind of "official" bootloader should be one of the next development efforts.

Giovanni

Raul
Posts: 43
Joined: Thu Aug 13, 2015 5:15 pm
Has thanked: 3 times
Been thanked: 1 time

Re: [DEV] STM32L5xx support

Postby Raul » Sat May 16, 2020 10:25 pm

Hi Giovanni,

What gdb server have you been using for this development? I've searched for OpenOCD support and only found this abandoned patch http://openocd.zylin.com/#/c/5386/

Raul

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [DEV] STM32L5xx support

Postby Giovanni » Sun May 17, 2020 7:03 am

Hi,

I have been using the ST-Link GDB server, It is in the ST IDE but it can be taken from within the exlipse plugin. You can run it like this:

Location:
${env_var:CHIBISTUDIO}/tools/ST/stlinkgdbserver/bin/ST-LINK_gdbserver

Working Directory:
${env_var:CHIBISTUDIO}/tools/ST/stlinkgdbserver/bin

Arguments:
-cp ${env_var:HOME}/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin -d -e

Note that you need to install the STM32CubeProgrammer too, it is used for flashing (and a very good tool in itself). In the debug configuration select "ST-Linl" as debugger (it is present in the latest Eclipse/ChibiStudio).

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 48 guests