Skip to content

mbed_retarget: Add a minimal console implementation to provide basic functionalities #11796

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

Conversation

hugueskamba
Copy link
Collaborator

@hugueskamba hugueskamba commented Nov 1, 2019

Description (required)

The retarget code allocates an array of FileHandle* for console and file
handling (filehandles). A tiny target only needs a console (putc/getc).
There is no need for file handling.

The POSIX layer and the array of FileHandle* is not required for small
targets that only need a console ; this code is optionally compiled
out if the configuration parameter platform.stdio-minimal-console-only is
set to "true".

Summary of change (What the change is for and why)

Add a minimal console implementation in mbed_retarget to provide basic functionalities.

Documentation (Details of any document updates required)

#11634

Pull request type (required)

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[X] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results (required)

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers (optional)

@kjbracey-arm


Release Notes (required for feature/major PRs)

Summary of changes

Add a minimal console implementation in mbed_retarget to provide basic console functionalities.
A new configuration parameter platform.stdio-minimal-console-only has been added to select it.

Impact of changes

Smaller memory footprint for applications that only require basic console functionalities.

Migration actions required

N/A

@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch from c204bf1 to a37de1c Compare November 1, 2019 13:04
@ciarmcom ciarmcom requested review from kjbracey and a team November 1, 2019 14:00
@ciarmcom
Copy link
Member

ciarmcom commented Nov 1, 2019

@hugueskamba, thank you for your changes.
@kjbracey-arm @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@evedon evedon left a comment

Choose a reason for hiding this comment

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

Great work.
Can you add in the "Release Notes" section of the PR that there is a new configuration option platform.stdio-minimal-console-only

@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch from a37de1c to 94a042d Compare November 1, 2019 15:24
@hugueskamba
Copy link
Collaborator Author

This force-push sets the default value of the platform.stdio-minimal-console-only parameter to false as existing applications and tests may rely on the use of the unbuffered serial class and/or APIs that are removed when the parameter is set to true.

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Looks like it should be a good saving. Can refine it a bit.

@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch 2 times, most recently from af99484 to 8eec656 Compare November 6, 2019 11:20
@hugueskamba
Copy link
Collaborator Author

hugueskamba commented Nov 6, 2019

The two force-pushes (this and this) addresses the first round of comments by @kjbracey-arm

@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch from 8eec656 to 1180b3c Compare November 7, 2019 08:15
@0xc0170 0xc0170 added needs: work release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 and removed needs: review labels Nov 7, 2019
@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch 6 times, most recently from 3bbd53d to 6e32242 Compare November 8, 2019 11:05
@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch 2 times, most recently from d00c27c to 584fb82 Compare November 8, 2019 11:30
@hugueskamba
Copy link
Collaborator Author

This force-push removes fdopen.

@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch from 584fb82 to af1ea58 Compare November 8, 2019 12:06
@kjbracey
Copy link
Contributor

The actual MinimalConsole class has vanished, so check for remaining references and remove.

@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch from e986995 to d8dd686 Compare November 11, 2019 13:05
@hugueskamba
Copy link
Collaborator Author

This force-push addresses the latest round of comments by @kjbracey-arm

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Few more adjustments... And see my comment about removing references to "class" and "MinimalConsole" - still there in commit message and GitHub description.

@hugueskamba hugueskamba changed the title mbed_retarget: Add an internal class to provide basic console functionality mbed_retarget: Add a minimal console implementation to provide basic functionalities Nov 11, 2019
@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch from d8dd686 to 2d21e53 Compare November 11, 2019 15:04
@hugueskamba
Copy link
Collaborator Author

This force-push addresses the latest round of comments by @kjbracey-arm.

…functionalities

The retarget code allocates an array of FileHandle* for console and file
handling (filehandles). A tiny target only needs a console (putc/getc).
There is no need for file handling.

The POSIX layer and the array of FileHandle* is not required for small
targets that only need a console ; this code is optionally compiled
out if the configuration parameter platform.stdio-minimal-console-only is
set to `"true"`.
@hugueskamba hugueskamba force-pushed the hk-add-minimal-console-to-retarget branch from 2d21e53 to 051991f Compare November 11, 2019 15:14
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 12, 2019

I'll review shortly, started CI meanwhile

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.

That looks good, but we need to document this option in our handbook. Why/when would you use it, what difference does it make and what are the consequences.

@JojoS62
Copy link
Contributor

JojoS62 commented Nov 12, 2019

as you are currently working on fdopen:
I have the problem that an class derives from Stream and implements putc. This works when it is compiled with gcc under windows, but same gcc version under MacOS produces mbed_die.
I've traced the problem and it happens in the constuctor of Stream, calling fdopen. This fdopen returns NULL, no valid filed handle. In my understanding, there must be an open handle fd that fdopen accepts. But I cannot find a open function that is called before. Is it possible that the fdopen function has different behaviour or am I overseeing a call of fopen somewhere before?

@kjbracey
Copy link
Contributor

I have the problem that an class derives from Stream and implements putc. This works when it is compiled with gcc under windows, but same gcc version under MacOS produces mbed_die.

The fdopen from Stream is an mbed-specific overload taking FileHandle * instead of int, implemented in mbed_retarget.cpp It uses the standard fdopen(int) internally. You should be able to single-step through enough to see whether the problem is in the Mbed OS half or the library fdopen.

Please create an issue if you want to continue the discussion - we shouldn't derail discussion on this PR.

@mbed-ci
Copy link

mbed-ci commented Nov 12, 2019

Test run: FAILED

Summary: 1 of 11 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test

@hugueskamba
Copy link
Collaborator Author

Test run: FAILED

Summary: 1 of 11 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test

@0xc0170 should the test just be re-started?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 13, 2019

Test restarted

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 13, 2019

All green now!

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.

8 participants