forked from adafruit/circuitpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This switches stage2 to C and uses Jinja to change the C code based on flash settings from https://github.com/adafruit/nvm.toml. It produces the fastest settings for the given set of external flashes. Flash size is no longer hard coded so switching flashes with similar capabilities but different sizes should *just work*. This PR also places "ITCM" code in RAM to save the XIP cache for code execution. Further optimization is possible. A blink code.py still requires a number of flash fetches every blink. Fixes adafruit#4041
- Loading branch information
Showing
31 changed files
with
411 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,2 @@ | ||
// LEDs | ||
// #define MICROPY_HW_LED_STATUS (&pin_PA17) | ||
|
||
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico" | ||
#define MICROPY_HW_MCU_NAME "rp2040" | ||
|
||
// #define DEFAULT_I2C_BUS_SCL (&pin_PA23) | ||
// #define DEFAULT_I2C_BUS_SDA (&pin_PA22) | ||
|
||
// #define DEFAULT_SPI_BUS_SCK (&pin_PB11) | ||
// #define DEFAULT_SPI_BUS_MOSI (&pin_PB10) | ||
// #define DEFAULT_SPI_BUS_MISO (&pin_PA12) | ||
|
||
// #define DEFAULT_UART_BUS_RX (&pin_PA11) | ||
// #define DEFAULT_UART_BUS_TX (&pin_PA10) | ||
|
||
// Flash chip is W25Q16JVUXIQ connected over QSPI | ||
#define TOTAL_FLASH_SIZE (2 * 1024 * 1024) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
MEMORY { | ||
/* We are loaded to the top 256 bytes of SRAM, which is above the bootrom | ||
stack. Note 4 bytes occupied by checksum. */ | ||
SRAM(rx) : ORIGIN = 0x20041f00, LENGTH = 252 | ||
} | ||
|
||
SECTIONS { | ||
. = ORIGIN(SRAM); | ||
.text : { | ||
*(.entry.*) | ||
*(.text.*) | ||
} >SRAM | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import sys | ||
import cascadetoml | ||
import pathlib | ||
import typer | ||
from jinja2 import Template | ||
|
||
|
||
def main(input_template: pathlib.Path, output_path: pathlib.Path, skus: str = typer.Argument("")): | ||
if ", " in skus: | ||
skus = skus.split(", ") | ||
else: | ||
skus = [skus] | ||
skus = ['sku="{}"'.format(f) for f in skus] | ||
flashes = cascadetoml.filter_toml(pathlib.Path("../../data/nvm.toml"), skus) | ||
|
||
if len(skus) == 0: | ||
print("Set EXTERNAL_FLASH_DEVICES in mpconfigboard.mk with all possible flash skus") | ||
raise typer.Exit(code=1) | ||
|
||
def all_have(nvms, key): | ||
for nvm in nvms: | ||
if not nvm.get(key, False): | ||
return False | ||
return True | ||
|
||
def all_match(nvms, key, default=None): | ||
shared_value = nvms[0].get(key, default) | ||
for nvm in nvms: | ||
this_value = nvm.get(key, default) | ||
if this_value != shared_value: | ||
print( | ||
"{}.{} = {} does not match {}".format( | ||
nvm["sku"], key, this_value, shared_value | ||
) | ||
) | ||
return None | ||
return shared_value | ||
|
||
quad_enable_status_byte = all_match(flashes["nvm"], "quad_enable_status_byte", 0) | ||
quad_enable_bit_mask = all_match(flashes["nvm"], "quad_enable_bit_mask") | ||
continuous_status_write = all_have(flashes["nvm"], "01_continuous_status_write") | ||
split_status_write = all_have(flashes["nvm"], "write_status_register_split") | ||
e7_quad_word_read = all_have(flashes["nvm"], "e7_quad_word_read") | ||
|
||
quad_ok = quad_enable_status_byte is not None and quad_enable_bit_mask is not None | ||
|
||
max_clock_speed_mhz = min((x.get("max_clock_speed_mhz", 1000) for x in flashes["nvm"])) | ||
|
||
# Check that we have a consistent way to set quad enable. | ||
if continuous_status_write is None and split_status_write is None: | ||
print("quad not ok", continuous_status_write, split_status_write) | ||
quad_ok = False | ||
|
||
clock_divider = 4 | ||
|
||
read_command = 0x03 | ||
wait_cycles = 0 | ||
if quad_ok: | ||
if e7_quad_word_read: | ||
read_command = 0xE7 | ||
wait_cycles = 2 | ||
else: | ||
read_command = 0xEB | ||
wait_cycles = 4 | ||
|
||
flash_settings = { | ||
"quad_ok": quad_ok, | ||
"quad_enable_status_byte": quad_enable_status_byte, | ||
"quad_enable_bit_mask": quad_enable_bit_mask, | ||
"split_status_write": split_status_write, | ||
"clock_divider": clock_divider, | ||
"read_command": read_command, | ||
"wait_cycles": wait_cycles, | ||
} | ||
|
||
template = Template(input_template.read_text()) | ||
|
||
output_path.write_text(template.render(flash_settings)) | ||
|
||
|
||
if __name__ == "__main__": | ||
typer.run(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,5 @@ USB_SERIAL_NUMBER_LENGTH = 16 | |
|
||
# Number of USB endpoint pairs. | ||
USB_NUM_EP = 8 | ||
|
||
INTERNAL_FLASH_FILESYSTEM = 1 |
Submodule sdk
updated
2 files
+1 −3 | src/rp2_common/hardware_flash/flash.c | |
+16 −0 | src/rp2_common/hardware_flash/include/hardware/flash.h |
Oops, something went wrong.