Skip to content

Enabling small C library option and deprecating uARM toolchain #12068

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
Jan 3, 2020

Conversation

rajkan01
Copy link
Contributor

@rajkan01 rajkan01 commented Dec 10, 2019

Summary of changes

  1. In Mbed-OS 2-region memory model, ARM Std and Microlib scatter files are common
    more info on https://github.com/ARMmbed/mbed-os/blob/master/docs/design-documents/platform/memory-model/ram_memory_model.md,
    so replaced ARM Std scatter file 1-region memory model with Microlib scatter file 2 region memory model.
  2. Moved the "__aeabi_assert" function from Microlib boot code file to mbed_retarget file so that it can be available for both RTOS Microlib and bare metal to resolve the undefined symbol linker issue.
  3. Copied ARM Microlib boot code into ARM std boot code and guarded with __MICROLIB. This is required in order to build a RTOS application with Microlib.
  4. Added a new target config "supported_c_libs" in targets.json and build tools to check if the selected "default_lib" is supported for the selected toolchain. If not the build tool will raise an exception.
  5. Added the new test suite for testing the build tool changes for default_lib and supported_c_libs.
  6. PR changes tested with blinky and blinky bare metal examples and greentea bare metal tests run locally.

Impact of changes

With these changes, uARM toolchain is being deprecated.

Migration actions required

As uARM toolchain is deprecated, the user has to redefine a supported_c_libs configuration with "small" for arm toolchain on the target in targets.json to enable Microlib support like

 "supported_c_libs": {
      "arm": ["std", "small"],
      "gcc_arm": ["std", "small"],
      "iar": ["std"]
  }

and change the scatter file to the 2-region memory model see more info.
Instead of -t uARM, use default_lib with "small" in mbed_app.json configuration for ARMC6 toolchain.

Documentation

ARMmbed/mbed-os-5-docs#1178


Pull request type

[] 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

[] 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

@evedon @hugueskamba @jamesbeyond @graham.hammond @mark.edgeworth @adrien.cabarbaye


@ciarmcom ciarmcom requested review from evedon, hugueskamba, jamesbeyond and a team December 10, 2019 14:00
@ciarmcom
Copy link
Member

@rajkan01, thank you for your changes.
@evedon @jamesbeyond @hugueskamba @ARMmbed/mbed-os-core @ARMmbed/mbed-os-tools @ARMmbed/mbed-os-test @ARMmbed/mbed-os-maintainers please review.

@bulislaw
Copy link
Member

By default, Mbed OS build tools use standard C library for all supported toolchains. It is possible to use smaller C libraries by overriding the "target.default_lib" option with "small". This option is only currently supported for the GCC_ARM toolchain. This override config option is now extended in the build tool for ARM toolchain.

default_lib was also renamed to c_lib right?

@rajkan01
Copy link
Contributor Author

By default, Mbed OS build tools use standard C library for all supported toolchains. It is possible to use smaller C libraries by overriding the "target.default_lib" option with "small". This option is only currently supported for the GCC_ARM toolchain. This override config option is now extended in the build tool for ARM toolchain.

default_lib was also renamed to c_lib right?

We will be doing this renaming from default_lib to c_lib in IOTCORE-1450 after this PR merged.

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.

@ARMmbed/team-st-mcd could you have a look at changes to the linker scripts?

"*": {
"K64F": {
"target.default_lib": "small",
"mbed-trace.fea-ipv6": false
Copy link
Member

Choose a reason for hiding this comment

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

What is that and why does it need to be set?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll let rajkumar answer. But mbed-trace.fea-ipv6 should have been overridden for all targets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"mbed-trace.fea-ipv6": false added to disable IPV6 tracing code in mbed_trace and we need mbed_trace due to dependency with the device key. More information on PR #11875

Copy link
Collaborator

@jeromecoutant jeromecoutant left a comment

Choose a reason for hiding this comment

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

Should you also remove all TOOLCHAIN_ARM_MICRO directory ?

and harmonize TOOLCHAIN_ARM_STD and TOOLCHAIN_ARMC6

"target.default_lib": "small"
},
"NUCLEO_F411RE": {
"target.default_lib": "small"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why target.default_lib is not set to small for all targets,
instead of adding a line for each 1...?

Copy link
Contributor Author

@rajkan01 rajkan01 Dec 16, 2019

Choose a reason for hiding this comment

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

It has only been set for targets that have been tested so far.

@rajkan01
Copy link
Contributor Author

Should you also remove all TOOLCHAIN_ARM_MICRO directory ?
and harmonize TOOLCHAIN_ARM_STD and TOOLCHAIN_ARMC6

@evedon please comment

@evedon
Copy link
Contributor

evedon commented Dec 16, 2019

Should you also remove all TOOLCHAIN_ARM_MICRO directory ?
and harmonize TOOLCHAIN_ARM_STD and TOOLCHAIN_ARMC6

@evedon please comment

We are deprecating TOOLCHAIN_ARM_MICRO but not removing it at this stage. This will be done in a future Mbed OS release.

@@ -51,6 +51,8 @@ static control_t test_printf_d(const size_t call_count)

/*************************************************************************/
/*************************************************************************/
#if !defined(__NEWLIB_NANO)
// The format specifier %hhd is not supported by Newlib-Nano
Copy link
Member

Choose a reason for hiding this comment

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

That doesn't make sense to me. These tests are for minimal-printf not for standard printf. I'm assuming they are being run in all cases even if the minimal-printf is not present and that's the problem. The thing is this change will possibly hide issues as we won't execute tests in usecase with minimal-printf and minimal clibs. I think the correct solution is to exclude all minimal-printf tests if minimal-printf is not used, but run them with newlib-nano + minimal-printf as the newlib-nano limitation won't be hit.

Copy link
Contributor

Choose a reason for hiding this comment

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

The user has the choice to swap the standard printf by minimal-printf ; mbed_printf is a test API that is always present (it calls mbed_minimal_formatted_string which is the minimal printf implementation).
But you are right that the limitation is a newlib-nano limitation and the test could check against a predefined value to avoid calling printf.

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 also a waste of time in the CI (even if not huge one) to test the stdlib. Sure it possible to find bugs there but it's rather rare.

 - By default, Mbed OS build tools use standard C library for all supported toolchains.
   It is possible to use smaller C libraries by overriding the "target.default_lib" option
   with "small". This option is only currently supported for the GCC_ARM toolchain.
   This override config option is now extended in the build tool for ARM toolchain.
 - Add configuration option to specify libraries supported for each toolchain per targets.
 - Move __aeabi_assert function from rtos to retarget code so it’s available for bare metal.
 - Use 2 memory region model for ARM toolchain scatter file for the following targets:
   NUCLEO_F207ZG, STM32F411xE, STM32F429xI, NUCLEO_L073RZ, STM32F303xE
 - Add a warning message in the build tools to deprecate uARM toolchain.
 - NewLib-Nano C library is not supporting floating-point and printf with %hhd,%hhu,%hhX,%lld,%llu,%llX
   format specifier so skipping those green tea test cases.
@bulislaw
Copy link
Member

My comments around disabling tests weren't addressed. It's not a huge problem, but with minimal amount of work we can do things properly. So unless I'm missing something could you please make sure the minimal-printf tests are not executed when minimal-printf is not used?

@rajkan01
Copy link
Contributor Author

rajkan01 commented Dec 23, 2019

My comments around disabling tests weren't addressed. It's not a huge problem, but with minimal amount of work we can do things properly. So unless I'm missing something could you please make sure the minimal-printf tests are not executed when minimal-printf is not used?

Minimal printf green tea test has changed to test without using std library printf and snprintf functions, please review.

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Dec 24, 2019

Test run: FAILED

Summary: 2 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-IAR
  • jenkins-ci/mbed-os-ci_build-ARM

@0Grit
Copy link

0Grit commented Dec 27, 2019

What are the effects if any on program memory / ram consumption?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 2, 2020

CI restarted

@mbed-ci
Copy link

mbed-ci commented Jan 2, 2020

Test run: FAILED

Summary: 1 of 12 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

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

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 2, 2020

test restarted

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 2, 2020

I'll review this one as well.

@0xc0170 0xc0170 added the release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 label Jan 3, 2020
Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

Once "Release Notes" are provided, LGTM

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 3, 2020

Once "Release Notes" are provided, LGTM

Oh, wait, reviewing the first template above (was it using older one) ? I'm checking now

@0xc0170 0xc0170 merged commit fc2a710 into ARMmbed:master Jan 3, 2020
@adbridge
Copy link
Contributor

adbridge commented Feb 17, 2020

@bulislaw does a deprecation (even of a compiler) count as a breaking change ? I've marked it as such for now, pending confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING-CHANGE release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.