-
Notifications
You must be signed in to change notification settings - Fork 3k
CM3DS Maintenance Pull Request: Memory changes (2/4) #6168
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Cortex-M3 Design Start Eval package example on MPS2+ board | ||
|
||
This folder includes the port of Mbed OS on the example system of the Cortex-M3 | ||
Design Start Eval package. This example is implemented in FPGA on the MPS2+ | ||
board. Please see this target's [Mbed page](https://os.mbed.com/platforms/ARM-CM3DS/) | ||
for more information. | ||
For convenience, this target is called **CM3DS**. | ||
|
||
## Compiling | ||
|
||
The target name is `ARM_CM3DS_MPS2`. You can compile Mbed OS | ||
projects for CM3DS with: | ||
|
||
```bash | ||
mbed compile -t COMPILER -m ARM_CM3DS_MPS2 | ||
``` | ||
|
||
Mbed OS supports the following compilers (replace `COMPILER` with): | ||
|
||
* `ARM` for Arm Compiler version 5. | ||
* `GCC_ARM` for GNU Compiler for Arm. | ||
* `IAR` for IAR compiler. | ||
|
||
## Running | ||
|
||
Because of the new memory configuration introduced in commit `CM3DS: switch to | ||
larger memories for code and data`, it | ||
has become easier (and portable among all compilers) to use `.elf` files | ||
instead of `.bin`. `.elf` files are now the default for CM3DS projects, and compilation | ||
generates only them. | ||
For `.elf` files to work, you need **at least version 2.2.5** of the MPS2+ | ||
firmware. For more information, please see the [firmware version 2.2.6 and instructions on how to put it | ||
in the MPS2+ board](https://community.arm.com/processors/designstart/f/discussions/9727/mps2-firmware-for-mbed). | ||
|
||
## Testing | ||
|
||
If you want to execute the Mbed OS greentea tests on CM3DS, you need | ||
**at least firmware version 2.2.6**. | ||
|
||
* `mbedls` does not automatically recognize which serial port is linked to the | ||
board. Check it manually, and create a file named `mbedls.json` containing | ||
(at the same level than where you execute all commands): | ||
|
||
```bash | ||
{ | ||
"50040200074D652F3828F333": { | ||
"serial_port": "/dev/ttyUSB0" | ||
} | ||
} | ||
``` | ||
|
||
Replace `/dev/ttyUSB0` with your correct serial port | ||
(something like `COM6` on Windows). | ||
|
||
* `mbedls` does not link CM3DS target ID with its name, so execute the command: | ||
|
||
```bash | ||
mbedls --mock 5004:ARM_CM3DS_MPS2 | ||
``` | ||
|
||
* You can now compile and run the tests: | ||
|
||
```bash | ||
mbed test -m ARM_CM3DS_MPS2 -t COMPILER | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/memory_zones.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* mbed Microcontroller Library | ||
* Copyright (c) 2018 ARM Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* This file contains the information of memory zones for code and data on | ||
* CM3DS. | ||
* It is used in startup code and linker scripts of supported compilers (ARM and | ||
* GCC_ARM). | ||
* | ||
* WARNING: IAR does not include this file and re-define these values in | ||
* MPS2.icf file. Please make sure that the two files share the same values. | ||
* | ||
* These memory zones are defined in section 4.1.1 of CM3DS Eval RTL and | ||
* Testbench User Guide. | ||
*/ | ||
|
||
#ifndef MEMORY_ZONES_H | ||
#define MEMORY_ZONES_H | ||
|
||
/* | ||
* Code memory zones | ||
* Please note that CM3DS on MPS2 does not contain any persistent flash memory. | ||
* The FLASH memory zone is a 256 KiB SRAM block in the FPGA and named FLASH | ||
* only to keep the same name than in the CM3DS Eval RTL and Testbench User | ||
* Guide. | ||
*/ | ||
#define FLASH_START 0x00000000 | ||
#define FLASH_SIZE 0x00040000 /* 256 KiB */ | ||
#define ZBT_SSRAM1_START 0x00400000 | ||
#define ZBT_SSRAM1_SIZE 0x00400000 /* 4 MiB */ | ||
|
||
/* Data memory zones */ | ||
#define SRAM0_START 0x20000000 | ||
#define SRAM0_SIZE 0x00008000 /* 32 KiB */ | ||
#define SRAM1_START 0x20008000 | ||
#define SRAM1_SIZE 0x00008000 /* 32 KiB */ | ||
#define SRAM2_START 0x20010000 | ||
#define SRAM2_SIZE 0x00008000 /* 32 KiB */ | ||
#define SRAM3_START 0x20018000 | ||
#define SRAM3_SIZE 0x00008000 /* 32 KiB */ | ||
#define ZBT_SSRAM23_START 0x20400000 | ||
#define ZBT_SSRAM23_SIZE 0x00400000 /* 4 MiB */ | ||
|
||
#endif /* MEMORY_ZONES_H */ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
like all includes in this PR, not using relative paths,
#include "memory_zones.h"
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 had to add the relative path because during the preprocessing step of the linker script, all folders are not included in the search path as it is done during compilation.
When I use
#include "memory_zones.h"
, the following command generates an error during mbed OS compilation process (compiling a random test as example):Adding
-I /fake_path/BUILD/tests/ARM_CM3DS_MPS2/GCC_ARM/targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/
, which is the folder containingmemory_zones.h
, at the end of the command resolves the issue. It is the same story forARM
compiler.Looking at it a bit closer:
For
GCC_ARM
, thelink
function intools/toolchains/gcc.py
preprocess the linker script before calling the link command (usingpreproc_output
path). I guess the preprocessing command could be enhanced with the path of every folder?For
ARM
compiler, the preprocessor is executed on the linker script thanks to the shebang at the beginning of the file so I could add the include path there. However thecorrect_scatter_shebang
function intools/toolchains/arm.py
will change it if it is not beginning with the correct format. This function could also add the path of every folder in the command.I am happy to raise an issue about it 😃
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.
Also, I had to rebase for the code to compile after #6229 was merged.
Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks for the info. I was not aware linker does not have the paths. Assuming not often linker needs to include another file.
@theotherjimmy What do you think? If a linker file needs an include, should it work with relative paths?
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.
It should never use absolute paths. They are not only not portable, but also not ever portable between users!
@0xc0170 You probably meant something other than absolute paths.
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 corrected the last reply from me, relative paths I meant as mentioned earlier above. OK to be in here ?
Thus the issue described #6168 (comment) is not an issue, by design and the only way to get inclusion in linker scripts is used relative paths?