Adafruit Feather RP2040 fixes #279

Closed
sandeepmistry wants to merge 1 commit from adafruit_feather_rp2040-fixes into develop-1.1.1
sandeepmistry commented 2021-03-23 12:25:33 -05:00 (Migrated from github.com)

The following changes are based on information from the Adafruit forum: https://forums.adafruit.com/viewtopic.php?f=57&t=176745&p=860819&hilit=rp2040#p860819

The pre-built CircuitPython .uf2 was working on my board, but none of the pico-examples were without the following SDK changes.

  1. The board has 8 MB of flash according to the product page: https://www.adafruit.com/product/4884

  2. CircultPython sets PICO_FLASH_SPI_CLKDIV to 4: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/Makefile#L237

  3. CircultPython uses boot2_generic_03h.S for boot2: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/Makefile#L236

There's probably a better have a board specific PICO_DEFAULT_BOOT_STAGE2_FILE value instead of editing src/rp2_common/boot_stage2/CMakeLists.txt - but I wanted to get the discussion going :)

The following changes are based on information from the Adafruit forum: https://forums.adafruit.com/viewtopic.php?f=57&t=176745&p=860819&hilit=rp2040#p860819 The pre-built CircuitPython .uf2 was working on my board, but none of the `pico-examples` were without the following SDK changes. 1) The board has 8 MB of flash according to the product page: https://www.adafruit.com/product/4884 2) CircultPython sets `PICO_FLASH_SPI_CLKDIV` to `4`: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/Makefile#L237 3) CircultPython uses `boot2_generic_03h.S` for boot2: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/Makefile#L236 There's probably a better have a board specific `PICO_DEFAULT_BOOT_STAGE2_FILE` value instead of editing `src/rp2_common/boot_stage2/CMakeLists.txt` - but I wanted to get the discussion going :)
hathach commented 2021-03-23 12:48:08 -05:00 (Migrated from github.com)

I encounter the issue with PICO_DEFAULT_BOOT_STAGE2_FILE as well, but not sure how to fix it. sdk probably need to have a way for board to specify its bootstage2. Currently it is done at application CMakeLists.txt

I encounter the issue with `PICO_DEFAULT_BOOT_STAGE2_FILE` as well, but not sure how to fix it. sdk probably need to have a way for board to specify its bootstage2. Currently it is done at application CMakeLists.txt
lurch commented 2021-03-23 20:06:33 -05:00 (Migrated from github.com)

See #275 😉
Also, it's (apparently) possible to have a board-specific cmake file in addition to / instead of a board-specific header file.

See #275 :wink: Also, it's (apparently) possible to have a board-specific cmake file in addition to / instead of a board-specific header file.
kilograham commented 2021-03-24 08:44:46 -05:00 (Migrated from github.com)

Yup, for PICO_BOARD=foo you can create a foo.cmake in boards/ or in another path set via PICO_BOARD_CMAKE_DIRS an that will be used to configure the build (including adding the board header to PICO_CONFIG_HEADER_FILES)... not too bad really, but the issue @lurch linked above will mean that you can just do it via your board header which is much easier

Yup, for `PICO_BOARD=foo` you can create a foo.cmake in boards/ or in another path set via `PICO_BOARD_CMAKE_DIRS` an that will be used to configure the build (including adding the board header to `PICO_CONFIG_HEADER_FILES`)... not too bad really, but the issue @lurch linked above will mean that you can just do it via your board header which is much easier
sandeepmistry commented 2021-03-24 10:08:27 -05:00 (Migrated from github.com)

@lurch @kilograham thanks for the link to #275 (and apologies for not taking a look at the issue list prior to opening this PR).

Would you prefer I drop commit https://github.com/raspberrypi/pico-sdk/pull/279/commits/57e51b46762a2c9a44705a17d392938c992c1eb5 from this pull request? Alternatively, as an interim solution, would it make sense for the default in src/rp2_common/boot_stage2/CMakeLists.txt to be boot2_generic_03h.S as this seems to be the plan in #275.

@lurch @kilograham thanks for the link to #275 (and apologies for not taking a look at the issue list prior to opening this PR). Would you prefer I drop commit https://github.com/raspberrypi/pico-sdk/pull/279/commits/57e51b46762a2c9a44705a17d392938c992c1eb5 from this pull request? Alternatively, as an interim solution, would it make sense for the default in `src/rp2_common/boot_stage2/CMakeLists.txt` to be `boot2_generic_03h.S` as this seems to be the plan in #275.
brentru commented 2021-03-24 14:54:20 -05:00 (Migrated from github.com)

@sandeepmistry Thanks for the PR, I was able to get blink/ from the examples working properly.

@sandeepmistry Thanks for the PR, I was able to get blink/ from the examples working properly.
tannewt commented 2021-03-24 15:22:45 -05:00 (Migrated from github.com)

Thanks for opening this PR! I was just about to look at this myself.

  1. CircultPython uses boot2_generic_03h.S for boot2: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/Makefile#L236

I just changed this. We now use our own templated C stage2 code that pulls flash info from our nvm.toml repo. This separates out the init code from specific flash skus. (It also uses 0xe7 quad word read which is 2 dummy cycles instead of 0xeb's four cycles.)

One reason the boot2_w25q080.S stage2 doesn't work because GigaDevice flash on the feather doesn't support two byte status register writes with the 0x01 command. Instead it supports 0x31 which writes the second status register byte directly. The Winbond chips support this too and it seems to be the trend. (0x01 on the winbond says it's backwards compatible to support two byte writes.)

I'd expect the 2 divisor to work with the quad setup after QE has been set. (The datasheet says commands work up to 80mhz.) However, it seems to be unreliable and the 4 divisor is a much safer bet.

Thanks for opening this PR! I was just about to look at this myself. > 3. CircultPython uses `boot2_generic_03h.S` for boot2: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/Makefile#L236 I [*just* changed this](https://github.com/adafruit/circuitpython/pull/4446). We now use our own [templated C stage2 code](https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/stage2.c.jinja) that pulls flash info from our [nvm.toml repo](https://github.com/adafruit/nvm.toml). This separates out the init code from specific flash skus. (It also uses 0xe7 quad word read which is 2 dummy cycles instead of 0xeb's four cycles.) One reason the `boot2_w25q080.S` stage2 doesn't work because [GigaDevice flash](https://github.com/adafruit/nvm.raw/blob/main/flash/gigadevice/GD25Q64C.pdf) on the feather doesn't support two byte status register writes with the 0x01 command. Instead it supports 0x31 which writes the second status register byte directly. The Winbond chips support this too and it seems to be the trend. (0x01 on the winbond says it's backwards compatible to support two byte writes.) I'd expect the 2 divisor to work with the quad setup after QE has been set. (The datasheet says commands work up to 80mhz.) However, it seems to be unreliable and the 4 divisor is a much safer bet.
kilograham commented 2021-03-24 18:51:07 -05:00 (Migrated from github.com)

@lurch @kilograham thanks for the link to #275 (and apologies for not taking a look at the issue list prior to opening this PR).

Would you prefer I drop commit 57e51b4 from this pull request? Alternatively, as an interim solution, would it make sense for the default in src/rp2_common/boot_stage2/CMakeLists.txt to be boot2_generic_03h.S as this seems to be the plan in #275.

I've move #275 into our next bug fix release, so nothing going to happen b4 then - yes please remove 57e4 tho (and rebase to develop-1.1.1)

> @lurch @kilograham thanks for the link to #275 (and apologies for not taking a look at the issue list prior to opening this PR). > > Would you prefer I drop commit [57e51b4](https://github.com/raspberrypi/pico-sdk/commit/57e51b46762a2c9a44705a17d392938c992c1eb5) from this pull request? Alternatively, as an interim solution, would it make sense for the default in `src/rp2_common/boot_stage2/CMakeLists.txt` to be `boot2_generic_03h.S` as this seems to be the plan in #275. I've move #275 into our next bug fix release, so nothing going to happen b4 then - yes please remove 57e4 tho (and rebase to develop-1.1.1)
sandeepmistry commented 2021-03-25 08:18:42 -05:00 (Migrated from github.com)

I've move #275 into our next bug fix release, so nothing going to happen b4 then - yes please remove 57e4 tho (and rebase to develop-1.1.1)

@kilograham done, please let me know if anything needs to be changed in this PR.

> I've move #275 into our next bug fix release, so nothing going to happen b4 then - yes please remove 57e4 tho (and rebase to develop-1.1.1) @kilograham done, please let me know if anything needs to be changed in this PR.
hathach commented 2021-03-25 09:30:50 -05:00 (Migrated from github.com)

See #275
Also, it's (apparently) possible to have a board-specific cmake file in addition to / instead of a board-specific header file.

Thanks @lurch That is great to know that we can add board-specific cmake file. while waiting for #275 should I add cmake for Feather rp2040 to dictate the boot stage2, or just wait for it since header only is nicer I guess.

> See #275 > Also, it's (apparently) possible to have a board-specific cmake file in addition to / instead of a board-specific header file. Thanks @lurch That is great to know that we can add board-specific cmake file. while waiting for #275 should I add cmake for Feather rp2040 to dictate the boot stage2, or just wait for it since header only is nicer I guess.
kilograham commented 2021-03-31 12:34:18 -05:00 (Migrated from github.com)

subsumed by #293

subsumed by #293
kilograham commented 2021-04-01 18:55:16 -05:00 (Migrated from github.com)

note 1.1.1 has been released which should fix feather issues

note 1.1.1 has been released which should fix feather issues

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!279
No description provided.