Skip to content

Added Mbed 2 to Mbed OS bare metal porting guide #1293

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 4 commits into from
Apr 22, 2020

Conversation

evedon
Copy link
Contributor

@evedon evedon commented Apr 13, 2020

No description provided.

@iriark01
Copy link
Contributor

Waiting for engineering review

@MarceloSalazar
Copy link
Contributor

Looks good - thanks!

@evedon evedon force-pushed the ed-mbed2-porting branch from 34cf877 to 4730530 Compare April 15, 2020 18:57
}
```

- It might be necessary to reduce the stack size allocated for your target if it does not have enough RAM. The stack size is configured by setting a value for the `boot-stack-size` attribute; this value must be a multiple of 8 for alignment purposes. By default all targets are configured to have a boot stack size of 0x1000 (4096 bytes) in bare metal. However, this must be overridden if inadequate for your target. We recommend to reduce the boot stack size to 0x400 (1096 bytes) if your target has 8KB of RAM and to 0x300 (768 bytes) if your target has 4KB of RAM.
Copy link
Contributor

Choose a reason for hiding this comment

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

0x400 is 1024 bytes

Copy link
Member

Choose a reason for hiding this comment

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

I'm not convinced, as far as I remember bare metal has only one stack. So the boot stack is the thread stack as well and the ISR stack.

0x400 (1096 bytes) if your target has 8KB of RAM
7K for global data and heap seems excessive. Also we'd like to have the applications pretty much portable if the stacks are different between different boards. The initial idea was that boards won't be allowed to play with stack sizes, only applications will be allowed to change them.

0x300 (768 bytes) if your target has 4KB of RAM.

Is it even possible to run Mbed on 4k board? Considering it's probably 8-16k flash...

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'm not convinced, as far as I remember bare metal has only one stack. So the boot stack is the thread stack as well and the ISR stack.

0x400 (1096 bytes) if your target has 8KB of RAM
7K for global data and heap seems excessive. Also we'd like to have the applications pretty much portable if the stacks are different between different boards. The initial idea was that boards won't be allowed to play with stack sizes, only applications will be allowed to change them.

0x300 (768 bytes) if your target has 4KB of RAM.

Is it even possible to run Mbed on 4k board? Considering it's probably 8-16k flash...

You are right that in bare metal the boot stack is the thread stack as well and the ISR stack. And that stack is defined to be 4K by default in https://github.com/ARMmbed/mbed-os/blob/master/targets/targets.json/#L60. For ultra constrained devices, it needs to be lowered.

LPC1114FN28: Flash 32kB, RAM 4kB was ported to bare metal ARMmbed/mbed-os@90d7e62; the recommendation to set boot-stack-size to 0x300 comes from that port.

Copy link
Member

Choose a reason for hiding this comment

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

OK, but this is an extreme example with target that small it doesn't make much sense to run Mbed and it makes even less sense for us to spend time on making it work. I'm afraid that this exceptions will lead to a mess when people see "oh you can do that as it's already done for this target". It would be more than reasonable to say that we require at least 32/48K of ROM and at 8K of RAM. How big is bare metal blinky these days?

}
```

- It might be necessary to reduce the stack size allocated for your target if it does not have enough RAM. The stack size is configured by setting a value for the `boot-stack-size` attribute; this value must be a multiple of 8 for alignment purposes. By default all targets are configured to have a boot stack size of 0x1000 (4096 bytes) in bare metal. However, this must be overridden if inadequate for your target. We recommend to reduce the boot stack size to 0x400 (1096 bytes) if your target has 8KB of RAM and to 0x300 (768 bytes) if your target has 4KB of RAM.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not convinced, as far as I remember bare metal has only one stack. So the boot stack is the thread stack as well and the ISR stack.

0x400 (1096 bytes) if your target has 8KB of RAM
7K for global data and heap seems excessive. Also we'd like to have the applications pretty much portable if the stacks are different between different boards. The initial idea was that boards won't be allowed to play with stack sizes, only applications will be allowed to change them.

0x300 (768 bytes) if your target has 4KB of RAM.

Is it even possible to run Mbed on 4k board? Considering it's probably 8-16k flash...

@evedon evedon force-pushed the ed-mbed2-porting branch from f3e7fc7 to b17e581 Compare April 17, 2020 15:46
@evedon evedon requested review from bulislaw and hugueskamba April 17, 2020 15:46
@evedon
Copy link
Contributor Author

evedon commented Apr 17, 2020

I have addressed all review comments. Could you please re-review?

@evedon evedon force-pushed the ed-mbed2-porting branch from f6aa714 to 180d538 Compare April 20, 2020 13:11
@evedon evedon requested a review from hugueskamba April 20, 2020 13:21
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.

Looks good. My only concern is the stack size configuration, but we merge this as is and decide on stack later.

Copy link
Contributor

@iriark01 iriark01 left a comment

Choose a reason for hiding this comment

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

I left some questions and suggestions.
Where it says "note to self" it's for me to do as a tidy-up before a merge.

@evedon evedon force-pushed the ed-mbed2-porting branch from 6edc58a to 250c462 Compare April 22, 2020 12:49
I will take another look at it on the preview branch to make sure all formatting works
@iriark01
Copy link
Contributor

Waiting on 6-beta release to merge and publish.

@evedon
Copy link
Contributor Author

evedon commented Apr 22, 2020

Code related PRs are all merged to master so you can merge this PR.

@iriark01 iriark01 merged commit 6193b29 into development Apr 22, 2020
iriark01 added a commit that referenced this pull request Apr 22, 2020
* Added Mbed 2 to Mbed OS bare metal porting guide

* Apply suggestions from code review

* Tidying up

I will take another look at it on the preview branch to make sure all formatting works

* Wording fix

Co-authored-by: Irit Arkin <[email protected]>
@evedon evedon deleted the ed-mbed2-porting branch April 23, 2020 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants