Skip to content

[feature-nrf528xx] NRF52832 and NRF52840 upgraded to Nordic SDK 14 and SoftDevice 5.0 #5845

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 8 commits into from
Jan 22, 2018
Merged

[feature-nrf528xx] NRF52832 and NRF52840 upgraded to Nordic SDK 14 and SoftDevice 5.0 #5845

merged 8 commits into from
Jan 22, 2018

Conversation

marcuschangarm
Copy link
Contributor

Initial commit for separating NRF52 code from the NRF51 and for
combining the NRF52832 and NRF52840 SDK to version 14.

nRF5_SDK_14.2.0_17b948a.zip has been used as baseline.

The folders in SDK/components:

  • ble
  • boards
  • device
  • drivers_nrf
  • libraries
  • softdevice

have been copied to TARGET_NORDIC/TARGET_NRF52/TARGET_SDK14.

Each folder contains a README.md file describing any modifications
made to that particular folder. Most common operation is deletion
of files.

If the need arise in the future the missing files can be added again.

The SoftDevices have been moved to TARGET_SOFTDEVICE_x folders for
flexible selection. Each folder contains a separate version of
SDK/config/sdk_config.h

@marcuschangarm marcuschangarm changed the title NRF52832 and NRF52840 upgraded to Nordic SDK 14 and SoftDevice 5.0 [feature-nrf528xx] NRF52832 and NRF52840 upgraded to Nordic SDK 14 and SoftDevice 5.0 Jan 12, 2018
@marcuschangarm
Copy link
Contributor Author

@pan- @bulislaw @0xc0170

Please review. Note the peripherals are still buggy. I would like to get this into the feature branch so that we can tag-team the missing features.

Overview:

  • TARGET_NORDIC/TARGET_NRF52 is a new folder for the NRF52 family.
  • TARGET_SDK14 contains a subset of Nordic's SDK version 14. The files have not been modified, but some files and folders have been deleted.
  • The target.json has been changed to point the NRF52 targets to the new folders.
  • The glue code between mbed HAL and Nordic SDK has been copied from the old directories with minor modifications.
  • Some of the peripherals do not work yet.

@ghost
Copy link

ghost commented Jan 13, 2018

this would be easier to review if it were split up into more commits.

@marcuschangarm
Copy link
Contributor Author

@jrobeson good point. I've split the initial commit into one big one and several smaller ones.

This PR is mainly the insertion of a new SDK and the copying over of files already in mbed OS. Once we get this new structure into a feature branch the real porting work of the missing non-working peripherals can begin.

@ghost
Copy link

ghost commented Jan 15, 2018

Is there a reason to keep SDK13? I've not dealt with nordic devices long eough to know if that's a thing people do. I see at least one TARGET_SDK13 check in there.

@marcuschangarm
Copy link
Contributor Author

That would be at a later stage:

  1. Update nrf52 to sdk 14
  2. Untangle nrf52 HAL from nrf51.
  3. Remove sdk 13.
  4. Update nrf51 to sdk 14
  5. Untangle nrf51 HAL from nrf52.
  6. Remove sdk 11.

@nvlsianpu
Copy link
Contributor

nvlsianpu commented Jan 15, 2018

Thanks for your efor @marcuschangarm !

We are analyzing SDK/Softdevice updates of our ports.
As Nordic we want to avoid NRF5 port scattering. So we definitely prefer to have TARGET_SDK14_2 on path
mbed-os\targets\TARGET_NORDIC\TARGET_NRF5\TARGET_SDK14_2 than copy-paste all NRF5 port. Duplication will increase efforts needed for maintenance.
It is also much better to have HAL driver implementation for a few SDK version at once than copy-paste them.

For Nordic port update we are expecting much more comitment - especiali BLE-port reworking, testing, hal driver fixing, hal driver testing.

@nvlsianpu
Copy link
Contributor

What I can suggestion Is that you can suspend this PR and wait for us a little (Can you answer to questions what your timeline?, which SoC do you want to use 1st with updated SDK? what company you represent?).

@nvlsianpu
Copy link
Contributor

BTW - I really like idea of renaming softdevice directories in the way that allow to chose proper softdevice using the mbed build system.

@marcuschangarm
Copy link
Contributor Author

Maintenance wise, I don't see how keeping the nrf51 and nrf52 HAL together will make things easier if that's what you mean by avoiding duplication?

If you want to take full advantage of the nrf52's new features the two implementations are going to be vastly different anyway.

@marcuschangarm
Copy link
Contributor Author

Regarding the time constraint, we need this work to proceed right now.

Can you offer a folder structure you would be happy with?

@MarceloSalazar
Copy link

This is only a PR to a feature branch that is served as discussion and collaboration with the Nordic team and the mutual developers/customers of this work.
Moreover, this is established process, similarly on how the Arm Mbed team is introducing new APIs and features. We need to support these devices asap.

@ghost
Copy link

ghost commented Jan 15, 2018

I'm glad to see this effort. It'd be nice to have signed boot images and the ability to use more code found on the internet that requires at least sdk 12. SDK 11 is just too old nowadays.

@nvlsianpu
Copy link
Contributor

Maintenance wise, I don't see how keeping the nrf51 and nrf52 HAL together will make things easier ...

Experience: We use to have separte ports for nrf51, nrf52823, nrf52840 before - amount of work needed for just supervising and bug-fixing was much more bigger than for currently one (TARGET_NRF5).

Folder structure:

  1. SDK14_2 components on path: "mbed-os/targets/TARGET_NORDIC/TARGET_NRF5/TARGET_SDK14_2"
    • The two drivers located her "mbed-os/targets/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF52832/sdk/driver_nrf/" should now be included in the new "TARGET_SDK14_2/driver_nrf". (i.e. deleted from the original location)
    • Folder "...\TARGET_NRF5/TARGET_SDK11/ ble_service /ble_dfu " shall not be included in the "TARGET_SDK14_2". Not in use
    • Include new driver “driver_nrf/rng”
    • Update the folder "mbed-os/targets/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF52832/sdk/softdevice/s132/" with the new SoftDevice S132 v5.1.0 (have to be downloaded separately using this link)
    • Update the folder "mbed-os/targets/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF52840/sdk/softdevice/s140/" with the new SoftDevice S140 v5.0.0-2.alpha.

After you add SDK14_2, it is need to rewrite the porting layer for the included modules to map to the changes in API's between SDK 11 and 14.2. Obviously it is reasonably to use macro TARGET_SDK14_2 for #ifdef with changes.

This could be useful information:
• There is no porting guide between SDK 11 and 12
• Migration guide (SDK v12 -> SDK v13)http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/migration.html?cp=4_0_4_1_7
• Migration guide (SDK v13 -> SDK v14) http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/migration.html?cp=4_0_2_1_7
• BLE port is based on pure SoftdeviceAPI in most of points - only SecureManager is basing on SDK (PM), maybe something more.
• The SoftDevice handler has been rewritten between SDK 13 and 14. Described in this guide
• Other BLE related fixes is also described here
• migration guide for SoftDevice API is bundled in its directory (both SDK one and separate downloaded one)

@pan-
Copy link
Member

pan- commented Jan 16, 2018

BLE port is based on pure SoftdeviceAPI in most of points - only SecureManager is basing on SDK (PM), maybe something more.

We're refactoring the SecurityManager module and adding a platform adaptation layer for it in the process. We look at the pure soft device API's to implement the PAL SecurityManager.

@marcuschangarm
Copy link
Contributor Author

Experience: We use to have separte ports for nrf51, nrf52823, nrf52840 before - amount of work needed for just supervising and bug-fixing was much more bigger than for currently one (TARGET_NRF5).

I would have to disagree. This only works if the mbed HAL implementation serves the lowest common denominator between the different MCUs and then you miss out on important features which is why people pick the more advanced MCU anyway. The current setup also makes it very difficult for people to contribute because you need knowledge of and access to all three devices to make any changes.

How about this compromise instead:

  • TARGET_NORDIC/TARGET_NRF5x/
  • TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51
  • TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52
  • TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832
  • TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_NRF52_DK
  • TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840
  • TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_NRF52840_DK
  • TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2

Common mbed HAL implementations that are truly shareable between NRF51 and NRF52 go in the TARGET_NRF5x root folder.

Peripherals that are different between NRF51 and NRF52 get their own mbed HAL implementation which goes into TARGET_NRF51 and TARGET_NRF52 respectively.

This is basically the setup every other partner implementation uses.

@screamerbg
Copy link
Contributor

screamerbg commented Jan 16, 2018

What @marcuschangarm explained above is also valid for the largest vendor family on mbed - STM32 (https://github.com/ARMmbed/mbed-os/tree/master/targets/TARGET_STM). Some of the implemented HAL features that are common for ALL STM32 families, while others are common per sub-family (STM32L0, STM32F4, etc), and some other are target specific.

@nvlsianpu I doubt that the nRF chips are vastly different, otherwise we wouldn't have SDK11 covering nRF51-DK and nRF52-DK (nRF52832), but also SDK13 compatible with both nRF52-DK and nRF52840-DK.

@0xc0170 This is a feature branch work and as such, this doesn't impact any of the release targets on the mbed OS official releases. As @MarceloSalazar described above, this is established process, similarly on how the Arm Mbed team is introducing new APIs and features on feature branches. We would like to use this feature branch as a collaborative effort to achieve better nRF5x support. Is there anything blocking this PR?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 17, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jan 17, 2018

Build : FAILURE

Build number : 884
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5845/

@nvlsianpu
Copy link
Contributor

@screamerbg

I doubt that the nRF chips are vastly different, .....

Yes, exactly they are so similar. BTW Even now nrf5 port is close to that what was proposed above.

@marcuschangarm
Copy link
Contributor Author

@nvlsianpu

BTW Even now nrf5 port is close to that what was proposed above.

So you are fine with the new structure I proposed?

Marcus Chang added 8 commits January 17, 2018 12:35
Initial commit for separating NRF52 code from the NRF51 and for
combining the NRF52832 and NRF52840 SDK to version 14.

nRF5_SDK_14.2.0_17b948a.zip has been used as baseline.

The folders in SDK/components:
 * ble
 * boards
 * device
 * drivers_nrf
 * libraries
 * softdevice

have been copied to TARGET_NORDIC/TARGET_NRF52/TARGET_SDK14.

Each folder contains a README.md file describing any modifications
made to that particular folder. Most common operation is deletion
of files.

If the need arise in the future the missing files can be added again.

The SoftDevices have been moved to TARGET_SOFTDEVICE_x folders for
flexible selection.

ble.h has been renamed to nrf_ble.h to avoid namespace clash with
mbed OS BLE.
Flash and RAM offsets have been modified to fit new SoftDevice
Flash and RAM offsets have been modified to fit new SoftDevice
Copied from previous location in targets/TARGET_NORDIC/TARGET_NRF5

Core functionality is working but some peripherals do not.
@cmonr
Copy link
Contributor

cmonr commented Jan 17, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jan 17, 2018

Build : SUCCESS

Build number : 888
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5845/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci
Copy link

mbed-ci commented Jan 17, 2018

@mbed-ci
Copy link

mbed-ci commented Jan 17, 2018

@nvlsianpu
Copy link
Contributor

@marcuschangarm I don't understand why you created brand new TARGET_NRF5x - why not put changes to currently existed TARGET_NRF5 - apart for that directory structure reorganization you proposed is fine.

@marcuschangarm
Copy link
Contributor Author

I want to keep a clean separation during the porting efforts to untangle dependencies. Once everything is done we can rename the directory back to NRF5 if you want.

@cmonr
Copy link
Contributor

cmonr commented Jan 18, 2018

Holding off on merging until @nvlsianpu gives the ok. Otherwise, this PR is good to go.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 19, 2018

I want to keep a clean separation during the porting efforts to untangle dependencies. Once everything is done we can rename the directory back to NRF5 if you want.

@nvlsianpu Does it make sense to keep this separation for now, this will be cleaned later? We would like to continue the work on the branch

@0xc0170 0xc0170 merged this pull request into ARMmbed:feature-nrf528xx Jan 22, 2018
@nvlsianpu
Copy link
Contributor

I was waiting on answer regard this for my management :( . For me this merge is OK - I didn't think we could dismiss this, I appreciated this efforts.

Once everything is done we can rename the directory back to NRF5 if you want

That's fine!

@marcuschangarm marcuschangarm deleted the feature-nordic-sdk14 branch January 24, 2018 16:00
@rerickson1
Copy link

Curious on the timeframe when the porting for the MBED BLE layer will be done to accommodate these changes?
I'm starting a project with the NRF52840 and I am very eager to start using SDK 14 with MBED.

@marcuschangarm
Copy link
Contributor Author

marcuschangarm commented Jan 29, 2018

@rerickson1 we are triaging the BLE part of the problem at the moment so unfortunately I don't have a timeframe yet.

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.

9 participants