Skip to content

Bring static pinmap extension to master #11892

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 65 commits into from
Nov 28, 2019

Conversation

mprse
Copy link
Contributor

@mprse mprse commented Nov 19, 2019

Description

In modern MCUs peripherals often can be mapped to different pins and each pin can have multiple functions. Mbed supports dynamic pin mapping, meaning that pins can be reconfigured at run time to be used by a different driver. That provides great flexibility, but it's not free. There's non-trivial ROM cost to maintain the pinmap tables and infrastructure to parse it. In some use cases, this flexibility is worth the cost. Quite often pin configuration is frozen at hw design stage and doesn't require runtime modification. Shifting this configuration to compile-time will allow us free memory associated with the dynamic approach.

Summary of change

HAL APIs making use of pins take these pins in their constructor and use those pins to lookup which peripheral/function to use. The process of looking up the peripheral/function requires there to be a pinmap table that maps pins to peripherals/functions. This pinmap table takes up ROM which could be saved if the pinmap wasn't used. The goal is to provide additional HAL API/constructors which takes pinmap as a parameter where pin/peripheral/function is specified statically and there is no need to use the pinmap tables. Also, add the constant expression utility functions to find pin mappings in compile time. This extension should give the following savings:

  • removed pinmap tables,
  • removed hal\mbed_pinmap_common library (required for pin lookup mechanism),
  • reduced HAL driver code.

More information can be found in the design document.

Documentation

Design doc:
https://github.com/ARMmbed/mbed-os/blob/feature-hal-spec-explicit-pinmap/docs/design-documents/hal/0003-static-pinmap-extension.md

Porting guide:
ARMmbed/mbed-os-5-docs#1156


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 (required)

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

Reviewers

@ARMmbed/mbed-os-hal


Release Notes

Summary of changes
  1. Provide types which will hold static pinmaps for peripherals(PWM, AnalogIn, AnalogOut, SPI, I2C, UART, QSPI, CAN).
  2. Provide xxx_init_direct(xxx_t *obj, static_pinmap_t *) functions to HAL API (these functions will not use pinmap tables).
  3. Provide additional constructors in drivers layer which will use the xxx_init_direct(xxx_t *obj, static_pinmap_t*) HAL functions.
  4. Provide default weak implementations of xxx_init_direct(static_pinmap_t *) functions. These functions will call standard xxx_init(xxx_t *obj, PinName, ...) function (backward compatibility for targets which do not support static pinmap mechanism).
  5. Provide constexpr utility functions to lookup for pin mapping in compile time (requires C++14).
  6. Initialize console using static pinmap mechanism, so hal\mbed_pinmap_common library is not needed and can be removed.
  7. Modify FPGA tests to verify xxx_init_direct(xxx_t *obj, static_pinmap_t*) APIs.

@ciarmcom ciarmcom requested review from maclobdell and a team November 19, 2019 12:01
@ciarmcom
Copy link
Member

@mprse, thank you for your changes.
@maclobdell @ARMmbed/mbed-os-core @ARMmbed/mbed-os-test @ARMmbed/mbed-os-hal @ARMmbed/mbed-os-maintainers please review.

@mprse
Copy link
Contributor Author

mprse commented Nov 19, 2019

cc @kjbracey-arm

@bulislaw
Copy link
Member

Before I start reviewing it, is the merge commit ok in a PR? @ARMmbed/mbed-os-maintainers

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 21, 2019

As this is targeting feature release, it would be. But simple rebase on the branch should remove it.

@mprse Can you rebase your branch and it should be nice linear log

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 21, 2019

@mprse Is this targeting 5.15 ? Or 6.0?

@bulislaw
Copy link
Member

5.15 if it can :P

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 skimmed the files only. LGTM

@kjbracey-arm

@0xc0170 0xc0170 requested a review from kjbracey November 21, 2019 14:58
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 22, 2019

We shall finalize reviews here today, please go ahead!

I'll do mine soon

@mprse mprse force-pushed the feature-hal-spec-explicit-pinmap branch from 3927aae to cd3989e Compare November 22, 2019 14:17
@mprse
Copy link
Contributor Author

mprse commented Nov 22, 2019

@mprse Can you rebase your branch and it should be nice linear log

Fixed

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 25, 2019

CI started

@0xc0170 0xc0170 requested review from a team and removed request for a team November 25, 2019 07:58
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 25, 2019

@mprse Can you not remove Release notes section (please add it back) ?

@mprse
Copy link
Contributor Author

mprse commented Nov 25, 2019

@mprse Can you not remove Release notes section (please add it back) ?

Fixed

@mbed-ci
Copy link

mbed-ci commented Nov 25, 2019

Test run: FAILED

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

Failed test jobs:

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

@mprse
Copy link
Contributor Author

mprse commented Nov 25, 2019

| K64F-GCC_ARM | K64F          | features-storage-tests-kvstore-general_tests_phase_1                         | FAIL   | 115.35             | default     | 
| DISCO_L475VG_IOT01A-ARMC6 | DISCO_L475VG_IOT01A | features-storage-tests-kvstore-direct_access_devicekey_test                  | TIMEOUT | 147.52             | default     |
| DISCO_L475VG_IOT01A-ARMC6 | DISCO_L475VG_IOT01A | features-storage-tests-kvstore-static_tests                                  | TIMEOUT | 329.23             | default     |
| DISCO_L475VG_IOT01A-ARMC6 | DISCO_L475VG_IOT01A | features-storage-tests-blockdevice-general_block_device                      | TIMEOUT | 323.21             | default     |
| DISCO_L475VG_IOT01A-ARMC6 | DISCO_L475VG_IOT01A | features-device_key-tests-device_key-functionality                           | TIMEOUT | 73.1               | default     |
| DISCO_L475VG_IOT01A-GCC_ARM | DISCO_L475VG_IOT01A | features-device_key-tests-device_key-functionality                           | TIMEOUT | 74.53              | default     |
| DISCO_L475VG_IOT01A-GCC_ARM | DISCO_L475VG_IOT01A | features-storage-tests-blockdevice-general_block_device                      | TIMEOUT | 325.74             | default     | 
| DISCO_L475VG_IOT01A-GCC_ARM | DISCO_L475VG_IOT01A | features-storage-tests-kvstore-static_tests                                  | FAIL    | 33.95              | default     | 
| DISCO_L475VG_IOT01A-GCC_ARM | DISCO_L475VG_IOT01A | tests-mbed_hal-qspi                                                          | FAIL    | 29.01              | default     | 
| DISCO_L475VG_IOT01A-IAR | DISCO_L475VG_IOT01A | features-device_key-tests-device_key-functionality                           | TIMEOUT | 72.05              | default     | 
| DISCO_L475VG_IOT01A-IAR | DISCO_L475VG_IOT01A | features-storage-tests-blockdevice-general_block_device                      | TIMEOUT | 323.19             | default     | 
| DISCO_L475VG_IOT01A-IAR | DISCO_L475VG_IOT01A | features-storage-tests-kvstore-static_tests                                  | FAIL    | 30.46              | default     | 
| DISCO_L475VG_IOT01A-IAR | DISCO_L475VG_IOT01A | tests-mbed_hal-qspi                                                          | FAIL    | 26.55              | default     | 
| NUCLEO_F411RE-ARMC6 | NUCLEO_F411RE | tests-mbed_hal-sleep_manager                                                 | FAIL   | 22.99              | default     | 
| NUCLEO_F411RE-IAR | NUCLEO_F411RE | tests-mbed_hal-sleep_manager                                                 | FAIL   | 23.02              | default     | 

A lot of tests have failed. I'm not sure if these failures are related to the changes. I haven't seen such failures while working on feature branch. If this requires further investigation I will continue when I will be back from sick-leave (Thursday). Meanwhile can we repeat the test run?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2019

The storage fix landed, as I can see this needs now one more change. Once done, let us know to start CI asap

@mprse mprse force-pushed the feature-hal-spec-explicit-pinmap branch from cd3989e to 2e79384 Compare November 28, 2019 11:45
@mprse
Copy link
Contributor Author

mprse commented Nov 28, 2019

Rebased and added the fix for STM QSPI driver.
Checked that tests-mbed_hal-qspi test now passes. This should also fix problems with storage tests (I run a few of them with positive results).

@0xc0170 Can we run CI again?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Nov 28, 2019

Test run: FAILED

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

Failed test jobs:

  • jenkins-ci/mbed-os-ci_wisun-mesh-test

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2019

jenkins-ci/mbed-os-ci_wisun-mesh-test

Failed prior restart, all fine here.

@mprse
Copy link
Contributor Author

mprse commented Nov 28, 2019

Test run: FAILED

It looks like all passed. The result is FAILED because jenkins-ci/wisun-mesh-test has failed, but was restarted and then passed.

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.

7 participants