Skip to content

Add NRF S140 7.0.1 #2801

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 2 commits into from
Apr 24, 2020
Merged

Add NRF S140 7.0.1 #2801

merged 2 commits into from
Apr 24, 2020

Conversation

xobs
Copy link

@xobs xobs commented Apr 22, 2020

This patch adds S140 v7.0.1, which Nordic says is the first version that supports the nRF52833.

xobs added 2 commits April 22, 2020 13:33
This is the first version with official support for nRF52833.

Signed-off-by: Sean Cross <[email protected]>
Previously, we were using v6.1.1 which worked, but was unsupported.
v7.0.1 is the first version of s140 that supports the nRF52833.

Signed-off-by: Sean Cross <[email protected]>
@xobs xobs mentioned this pull request Apr 22, 2020
@dhalbert
Copy link
Collaborator

Just to confirm, you loaded the 7.0.1 SD on your board as well when you tested?

@xobs
Copy link
Author

xobs commented Apr 22, 2020

Yes, I've updated the bootloader as well (see https://github.com/simmel-project/bootloader) and I'm loading 7.0.1 of the SD.

@hathach
Copy link
Member

hathach commented Apr 22, 2020

the flash size for SD v7 0x27000 while v6 is 0x26000, did you update both flash layout for bootloader and circuitpython. I don't quite see the linker script changes in the commit diff.

@dhalbert
Copy link
Collaborator

the flash size for SD v7 0x27000 while v6 is 0x26000, did you update both flash layout for bootloader and circuitpython. I don't quite see the linker script changes in the commit diff.

I worried about this too, but it turns out I parameterized it when I parameterized the .ld file:

FLASH_SD (rx) : ORIGIN = ${SD_FLASH_START_ADDR}, LENGTH = ${SD_FLASH_SIZE}

@hathach
Copy link
Member

hathach commented Apr 22, 2020

the flash size for SD v7 0x27000 while v6 is 0x26000, did you update both flash layout for bootloader and circuitpython. I don't quite see the linker script changes in the commit diff.

I worried about this too, but it turns out I parameterized it when I parameterized the .ld file:

FLASH_SD (rx) : ORIGIN = ${SD_FLASH_START_ADDR}, LENGTH = ${SD_FLASH_SIZE}

that is too smart, Dan 💯

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

This looks good!

In the long run it might be nice to use a submodule for the SD header files, though I'm not sure how we would have two versions available at once.

I will not merge yet pending any comments by anyone else.

@dhalbert dhalbert requested a review from hathach April 22, 2020 16:01
@xobs
Copy link
Author

xobs commented Apr 22, 2020

That definitely would explain why my flash space shrunk by about 4096 bytes when I made the change.

@hathach
Copy link
Member

hathach commented Apr 22, 2020

That definitely would explain why my flash space shrunk by about 4096 bytes when I made the change.

Did you change the bootloader knowledge of application size and starting address !!!

@xobs
Copy link
Author

xobs commented Apr 22, 2020

I'm unsure of how it worked, but somehow it did. I have a feeling there's something in the UICR region that told it where to go, or possibly based on macros such as SD_SIZE_GET(MBR_SIZE) that are imported from the nrf headers.

@hathach
Copy link
Member

hathach commented Apr 22, 2020

I'm unsure of how it worked, but somehow it did. I have a feeling there's something in the UICR region that told it where to go, or possibly based on macros such as SD_SIZE_GET(MBR_SIZE) that are imported from the nrf headers.

No it is not that good https://github.com/simmel-project/bootloader/blob/simmel/src/usb/uf2/uf2cfg.h#L12
I am actually updating the bootloader repo for supporting self-updating with uf2 and also cross-version v6 <-> v7 support. I am not sure why it works out so well for you, maybe it is worth further analyzing.

@dhalbert maybe it is a good reason for us to upgrade to v7 :D . I will resume to bootloader work shortly.

@tannewt
Copy link
Member

tannewt commented Apr 22, 2020

I'm totally game for this! Do we need to update the UF2 bootloader along with it?

@dhalbert
Copy link
Collaborator

I'm totally game for this! Do we need to update the UF2 bootloader along with it?

Yes, the bootloader includes the SoftDevice. So if we update CPy to v7.0.1, the user has to update both, and can't roll back just one. So it's kind of a big deal.

We don't yet a have self-updater for the bootloader: it's hard because once the bootloader protection is set, you can't undo it to write the bootloader. We could fix that in a new bootloader, but not in the current one, I think. So I think the user has to do a DFU or SWD update at least once.

@xobs
Copy link
Author

xobs commented Apr 23, 2020

No it is not that good

I see. In that case, I assume it worked because 0x26000 is within the region that's reserved for BLE pairings on my board, and I didn't pair any BLE devices. I've since replaced it with a macro, so now it should be loading at the correct address: https://github.com/simmel-project/bootloader/blob/simmel/src/usb/uf2/uf2cfg.h#L12

I think that updating the bootloader and softdevice is a major enough event that it's not worth it for most customers. I saw all sorts of hooks inside the bootloader to update the SD, but I've mostly patched them out. It's not possible to update SD via UF2.

There shouldn't be a problem with having two different versions of the SD, especially since they seem to be mostly API (and ABI?) compatible. The risk comes mostly in using API calls that only exist in one version of the SDK, but that's what CI is for right?

@xobs
Copy link
Author

xobs commented Apr 23, 2020

Oh. No, the reason why it works is because UF2 encodes the address as part of the file, and the bootloader was just honoring the addresses generated by circuitpython. The invalid USER_FLASH_START address just means that the UF2 file is capable of overwriting the SD, but because circuitpython has the correct addresses it won't actually do so.

Also, my USER_FLASH_END variable is incorrect. And the UF2_FAMILY_ID is still 0xADA52840 even for nrf52833. Hmm...

@hathach
Copy link
Member

hathach commented Apr 23, 2020

Oh. No, the reason why it works is because UF2 encodes the address as part of the file, and the bootloader was just honoring the addresses generated by circuitpython. The invalid USER_FLASH_START address just means that the UF2 file is capable of overwriting the SD, but because circuitpython has the correct addresses it won't actually do so.

Also, my USER_FLASH_END variable is incorrect. And the UF2_FAMILY_ID is still 0xADA52840 even for nrf52833. Hmm...

Yeah, exactly, the uf2 isn't included the address that overwrite the portion of SD. But it could run into issue with uf2 from another board such as 52840. Regarding the self-updater for bootloader, it is actually possible, Dan thought I implemented write protection for bootloader, but hehe I am too lazy and only open an issue for that and didn't do anything just yet. Therefore it is entirely possible, in fact I was working on self updater with uf2 for bootloader here before switching to esp32s2 port

https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/self-uf2/src/usb/uf2/uf2cfg.h

One of the issue with update bootloader is making sure it will only flash the bootloader of that particular board e.g feather_nrf52840 express should reject the CLUE bootloader u2f. I intend to include the VID/PID to uf2 file but didn't find a std way to do so. @dhalbert @xobs we can move the discussion with related uf2 updater to its own issue here adafruit/Adafruit_nRF52_Bootloader#24 if you have more idea on how it should be done.

@xobs
Copy link
Author

xobs commented Apr 24, 2020

This patch does two things:

  1. Add s140 v7.0.1 as an option to build, and
  2. Switch nrf52833 to use v7.0.1

Since this is the minimum supported version for that chip, and while 6.1.1 works (but is not supported by the vendor), are there any blockers for integrating this into circuitpython?

There's a lot of discussion here about how to update nrf52840 boards, but I suspect that should be a separate topic, since nrf52833 shouldn't ever really be running v6.1.1.

@dhalbert dhalbert merged commit 982a755 into adafruit:master Apr 24, 2020
@dhalbert
Copy link
Collaborator

It's fine! I was just waiting for extra vetting, but I see no reason not to proceed.

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.

4 participants