-
Notifications
You must be signed in to change notification settings - Fork 109
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
Enable stm32 core coupled memory #897
Conversation
Import origional libopencm3 linker script. Signed-off-by: Winford <winford@object.stream>
Enable using the Core Coupled Memory present in all stm32f4 and other mid to high end stm32 MCUs. The 64k CCM is used for `.data` and `.bss` segments (aprox 2.5k) as well as the `stack` for the VM. This leaves more of the 256k of slower sram available for user application stack and heap. Interrupt handler code may also be placed in the core coupled memory, this will eliminate delays from loading the interupt handler function from flash. Signed-off-by: Winford <winford@object.stream>
Interrupt handlers should be placed in CCM to avoid delays loading the handler function from flash. Remove `TRACE` lines from within `exti#_isr` handlers and added extra diagnosic info in `isr_handler`, because the console print used by `TRACE` is a blocking function and should not be used inside interrupt handlers. Signed-off-by: Winford <winford@object.stream>
88069e9
to
738f5c2
Compare
Can you explain what these changes to in the description? I am not really versed on the STM32, so it might be good for us to have something here for posterity. |
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an issue distributing this under the Apache 2.0 license? I am not sure what the implications are of this. @bettio any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to avoid (L)GPL only sources, in order to keep licensing simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then maybe we really need to consider basing this port on something other than libopencm3 as it is licensed under GPL-3.0, LGPL-3.0 licenses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one GPL/Apache 2.0 question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts about this PR:
- Do we have any performance measurement?
- When we take an existing source file we should clearly mark what we changed (this is useful in a number of scenarios). This is not clear to me at first glance
- Can we get the same result without using an entire linker script?
- We should discuss how to handle the licensing issue
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to avoid (L)GPL only sources, in order to keep licensing simple.
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* SPDX-License-Identifier: LGPL-2.1-or-later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tag is wrong anyway I think.
I do have some performance metrics using @pguyot 's atomvm_benchmark. Master:
With CCM enabled:
Equally important is that more sram is available for stack and heap in user beam applications, by moving the VM stack to the core coupled memory. I do not think there is any other way to assign the stack to CCM, as this is one of the two primary roles of the linker script, to let the mcu know where the various memory peripherals should be mapped. |
Since the format of the linker script is dictated by the In fact after further looking I believe libopencm3 might be in the wrong for using the lgpl-3 license as their script looks suspiciously similar to the BSD-3 license used by STMicroelectronics for the reference linker script, as seen in a version used by Mbed-OS for their stm32 support: |
As far as making the changes clear, this is why I did not flatten the first two commits, but adding a comment before each change would probably be helpful for future maintainers to see exactly which sections of memory have been moved from default |
I Have been looking further and there does seem to be a way to enable this in the application rather than the linker. I will see if I can get it working programmatically. |
Enable using the Core Coupled Memory present in all stm32f4 and other mid to high
end stm32 MCUs. CCM is faster than sram as it is tightly integrated with the processor. The 64k CCM is used for
.data
and.bss
segments (aprox 2.5k)as well as the
stack
for the VM. This leaves more of slower sramavailable for user application stack and heap. Interrupt handler code may also be
placed in the core coupled memory, this will eliminate delays from loading the
interupt handler function from flash. Overall performance could potentially be improved by placing frequently used functions into CCM using
__attribute(section("ccm"))__
.These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later