Skip to content

Reregistration GR-PEACH as mbed support board #5530

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

Closed
wants to merge 0 commits into from

Conversation

TomoYamanaka
Copy link
Contributor

Description

By #5342, since Cortex-A was supported wtih updating CMSIS/RTX, I request that GR-PEACH is registed as mbed board again.
Therefore, I PR the process that depend on GR-EPACH, and more.

Request

@toyowata
Please help me to go ahead with the above.

@TomoYamanaka TomoYamanaka changed the title Retarget GR-PEACH as mbed support board Reregistration GR-PEACH as mbed support board Nov 20, 2017
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 20, 2017

I would like to compile the Cortex-A boards that is supported as Mbed.
To do that, it's necessary to change the python file in "tools".
In "tools/build_api.py", please remove the processing done by #4415.

This should be part of this PR, or should be done as separate patch and this commited on top of it, to test these changes.
@theotherjimmy Can we just revert the PR 4415 as whole? Please advise

@TomoYamanaka Was this tested with the modifications (reverting locally 4415) ?

@TomoYamanaka
Copy link
Contributor Author

@0xc0170

@TomoYamanaka Was this tested with the modifications (reverting locally 4415) ?

Of course. I tested with modification it. :)

There was a lack in the above description. I needed to modify "tools\toolchains\arm.py" too.
b0fc103#diff-9cf75aea879b6b9cc5026af0b8f708a3R37
I added "Cortex-A" in arm.py because I couldn't compile by ARMCC.

@theotherjimmy
Copy link
Contributor

@TomoYamanaka @0xc0170 That PR was designed to be reverted at a later date. Please feel free to revert.

@TomoYamanaka
Copy link
Contributor Author

@theotherjimmy

That PR was designed to be reverted at a later date. Please feel free to revert.

I reverted "Remove Cortex-A mbed OS 5 support".

Also,

There was a lack in the above description. I needed to modify "tools\toolchains\arm.py" too.

I added Cortex-A for core support in ARM toolchain.

@@ -62,6 +62,7 @@ void us_ticker_init(void) {
// INTC settings
InterruptHandlerRegister(US_TICKER_TIMER_IRQn, (void (*)(uint32_t))us_ticker_interrupt);
GIC_SetPriority(US_TICKER_TIMER_IRQn, 5);
GIC_SetConfiguration(US_TICKER_TIMER_IRQn, 3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit msg:

Change the processes that depend on GR-EPACH.

  • These files are based on the codes of CMSIS5/RTX5 for RZ/A1H incorporated in DS-5.
  • I modified the support range from Mbed OS 2 to Mbed OS 2 and 5.
  • In "mbed_rtx.h", I changed the values depend on GR-PEACH like a other targets for Cortex-M.

Is this change related to the first one These files are based on the codes of CMSIS5/RTX5 for RZ/A1H incorporated in DS-5. ? What does this change do? Changes like this should be in a separate commit - what is fixing and how.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the codes of CMSIS5/RTX5 for RZ/A1H incorporated in DS-5, GIC_SetConfiguration is a newly added function as Cortex-A, this function sets the interrupt configration using GIC.
It seems that this processing has become necessary for interrupt of each driver to work properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that answers it. Please consider this type of details to be part of the change (using git commit message).

You can amend the commit msg to include there this detail for the reader, it would answer my question.

Copy link
Contributor Author

@TomoYamanaka TomoYamanaka Nov 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I amended the commit msg(8863d14). Make a sense?

@@ -187,7 +187,11 @@ osThreadAttr_t _main_thread_attr;
#ifndef MBED_CONF_APP_MAIN_STACK_SIZE
#define MBED_CONF_APP_MAIN_STACK_SIZE 4096
#endif
#if defined(__CORTEX_A9)
MBED_ALIGN(8) char _main_stack[MBED_CONF_APP_MAIN_STACK_SIZE*4];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we cant use the default one (*4 here)? This is breaking this config. As a user would set it to 10k for instance, actually would get 40k.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change refer in the processing of previous mbed-os version.
Reference is here.
I think Cortex-A in general will require more stack space more than Cortex-M.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we can see, some changes like this would be good to have as a separate commit with description to understand the reason for this change.

The default value should be rather changed. It is set on the line 188 in this file. As we would need to do *4 for any line that uses it in this file.

I think Cortex-A in general will require more stack space more than Cortex-M.

4k by default would not be sufficient to run mbed-os examples ? If we agree that Cortex-A should have 4x more stack by default than cortex-m, then we would need:

#if cortex-a
// default stack is 16k
#else
// default stack is 4k
#endif

@bulislaw Please check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to set it to 4K by default for all platforms and make it configurable for applications. Overwriting it silently like that is confusing. Why do we need to do that? Is 4K not enought to run basic Mbed Apps and examples?

Copy link
Contributor Author

@TomoYamanaka TomoYamanaka Nov 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of this test, Executing with #define THREAD_STACK_SIZE 256 in Cortex-A, program will abort because of the lack of stack.
Even threads that only execute malloc and free, it seems that it will make a difference in the stack used between Cortex-A and Cortex-M.
As a result of check, in Cortex-A, program will work properly by #define THREAD_STACK_SIZE 512 at least.
(Now the value of macro I committed is 2048, I will change to 512)

This is why, Cortex-A needs more stack size than Cortex-M.
Since this value(16K) may be too large, how about change to 8K by following the above size? (Cortex-A is twice Cortex-M)
Could you give me your opinion about the above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xc0170 @bulislaw
I will appreciate if you reply this promptly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave the MBED_CONF_APP_MAIN_STACK_SIZE as it is for all platforms. The question above was not answered, if 4k is not sufficient for mbed OS app. Did you have any failures with it - tests or examples?
This is application specific, it is intended to be tuned by application.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xc0170
Thank you for your commnets.
I understood the specification of MBED_CONF_APP_MAIN_STACK_SIZE.
To be honest, I was worried about the lack of the stack by any chance, there was no problem for mbed test in case of 4K.
Therefore, I will modify to revert the value of macro to 4K soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I committed.

@@ -2356,11 +2356,12 @@
"core": "Cortex-A9",
"program_cycle_s": 2,
"extra_labels": ["RENESAS", "MBRZA1H"],
"macros": ["TARGET_FEATURE_EXTENSION_REGISTER_COUNT_GCC=32", "TARGET_FEATURE_EXTENSION_REGISTER_COUNT_IAR=32"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does these 2 macro do? Would it be better to put into the config, instead of macro ?

I can see it is used in the rtx assembly files, are these also part of RTX ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original was the form of TARGET_FEATURE_EXTENSION_REGISTER_COUNT.
However, since this macro is a built-in environment variable of the ARM compiler,
in the case of GCC or IAR, this macro is became un-active, either process related to VFP does not run.
The macro here should be the target dependent value. In order to run the processing with the register count 32 as same previously,
I prepared the renamed macro, I actived it's processes in GCC and IAR.
Finally there was no a file is included in RTX assembly file, so I defined a macro in targets.json.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this via config, see an example: https://github.com/ARMmbed/mbed-os/blob/master/targets/targets.json#L269. Rather than macro with some value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a result of cherry-picking fixes from official CMSIS repo please, the macro that I added in targets.json became unnecessary. So I reverted the change of its file.

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't want to change CMSIS files in Mbed OS when we can help it. These should be dicussed with CMSIS folk and broguht there and then cherry-picked on Mbed until we do next code drop.
@JonatanAntoni could you look at the changes to cmis/ directory and see if you would be willing to accept them to CMSIS?
@theotherjimmy can you review changes to tools please

@@ -391,13 +391,13 @@ osRtxContextSave:

VMRS R2, FPSCR
STMDB R3!, {R2,R12} // Push FPSCR, maintain 8-byte alignment
#if TARGET_FEATURE_EXTENSION_REGISTER_COUNT == 16
#if TARGET_FEATURE_EXTENSION_REGISTER_COUNT_GCC == 16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We fixed that issue in the meanwhile. Please check with latest CMSIS release if this works for you.

;ORR R2, R2, #2
;STRB R2, [R0, #TCB_SP_FRAME]
;ENDIF
;IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT_IAR} == 32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We fixed this issue on latest CMSIS release.

#include "rtx_core_cm.h"
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to access this internal RTX header?
A user should never need to rely on RTX implementation details like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually think it's needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that it implemented by this commit (4b354f8#diff-415fd494349b5414064e0cc0d9f0d596).
In cortex-A, the build error occurs by including "rtx_core_cm.h". Therefore I implemented to include the header file for Cortex-A("rtx_core_ca.h").

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure rtx_core_cm.h contains the core abstraction for Cortex-M, so this cannot be used for Cortex-A. I strongly recommend not to rely on internal stuff. Actually the include (formerly core_cm.h) was introduced in #e44d94f. Can you point out what you need that's defined in this header?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed and can be deleted. I'll submit an PR to do it.

{
//Disable the SPI interrupt
GIC_DisableIRQ(i);
GIC_DisableIRQ((IRQn_Type)i);
if (i > 15) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i starts at 32, thus this condition is always true.
We fixed GIC implementation in latest CMSIS release.

@@ -581,6 +603,13 @@ void __FPU_Enable(void)
}


__STATIC_INLINE
int __disable_irq_iar() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not the intention of CMSIS to incorporate device and/or compiler specific functions. All functions (API) shall rather be implemented for all compilers in this case. It seems you are looking for a extended version of __disable_irq() that returns the value of CPSR before modification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this function by cherry-picking from CMSIS repo, implemented disable_irq() for IAR by utilizing mbed critical function.

@bulislaw
Copy link
Member

@TomoYamanaka Instead of fixing it yourself, could you cherry pick fixes from official CMSIS repo please? All the other modifications to CMSIS should be submitted and accepted to CMSIS repo as well and then cherry picked on top of Mbed.

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add "Cortex-A9" to ARMC6's supported core list as well?

@TomoYamanaka
Copy link
Contributor Author

@bulislaw
Now, I'm preparing to cherry-pick them, so can you wait a second?

@theotherjimmy

Could you add "Cortex-A9" to ARMC6's supported core list as well?

I commited this change.

@TomoYamanaka
Copy link
Contributor Author

I cherry-picked fixes from official CMSIS repo please.
And I modifid the macro of "THREAD_STACK_SIZE" using malloc test to 512B.

@bulislaw
Copy link
Member

I'm sorry that's not cherry picking: 66aea98 could we have actual commits 1 to 1 from the CMSIS repo so we know which fixes we actually have.

@bulislaw
Copy link
Member

These commit still change CMSIS/RTX:
54a3e56
21d0d31

If they are not longer needed because of the 'cherry-picking' please remove them. If they are still needed can we submit them to CMSIS/RTX repo?

@TomoYamanaka
Copy link
Contributor Author

@bulislaw
Thank you for your kindness.
I will try again.

@TomoYamanaka
Copy link
Contributor Author

TomoYamanaka commented Nov 28, 2017

@bulislaw

I cherry-picked from CMSIS repo.
Also I changed the method of disable_irq() / enable_irq() in each drivers.

If they are not longer needed because of the 'cherry-picking' please remove them. If they are still needed can we submit them to CMSIS/RTX repo?

I adjusted the contents of CMSIS repo, but in IAR toolchain, there were two changes needed to run GR-PEACH in cmsis_iccarm.h.
6239ec0
31ce59a

Could you sumit them to CMSIS repo ?

@bulislaw
Copy link
Member

@TomoYamanaka I'm sorry I can't see anything in this history, can you remove all the unnecessary commits rather than overwrite them and change back and forth? The log should be clean as we are reviewing commit by commit and also it'll end up in the Mbed OS history.

Also if your commits will be structured as follows it will build a coherent story and make all our lives easier.
1..a) Changes to PEACH code
a..b) Changes to Mbed OS including reverting disabling the Cortex A
b..c) Cherry-picked changes from CMSIS/RTX
c..d) New changes to CMSIS/RTX that @JonatanAntoni can review and then can be submitted to https://github.com/ARM-software/CMSIS_5/

@TomoYamanaka
Copy link
Contributor Author

I've closed This pull request by mistake, so I will PR again soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants