Merge pull request #5035 from tannewt/correct_a2040_flash
Fix Arduino RP2040 flash size
This commit is contained in:
commit
10645bf538
|
@ -260,6 +260,12 @@ $(BUILD)/stage2.c: stage2.c.jinja gen_stage2.py | $(BUILD)/
|
|||
$(STEPECHO) "GEN $<"
|
||||
$(Q)$(PYTHON3) gen_stage2.py $< $@ $(EXTERNAL_FLASH_DEVICES)
|
||||
|
||||
$(HEADER_BUILD)/flash_info.h: flash_info.h.jinja gen_stage2.py | $(HEADER_BUILD)/
|
||||
$(STEPECHO) "GEN $<"
|
||||
$(Q)$(PYTHON3) gen_stage2.py $< $@ $(EXTERNAL_FLASH_DEVICES)
|
||||
|
||||
$(BUILD)/supervisor/internal_flash.o: $(HEADER_BUILD)/flash_info.h
|
||||
|
||||
$(BUILD)/boot2.elf: $(BUILD)/stage2.c
|
||||
$(STEPECHO) "BOOT $<"
|
||||
$(Q)$(CC) $(CFLAGS) $(BOOT2_S_CFLAGS) -Os -ggdb3 -I. -fPIC --specs=nosys.specs -nostartfiles -Wl,-T,boot_stage2.ld -Wl,-Map=$@.map -o $@ $<
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// This file is auto-generated using gen_stage2.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FLASH_DEFAULT_POWER_OF_TWO {{ default_power_of_two }}
|
|
@ -1,3 +1,4 @@
|
|||
import math
|
||||
import sys
|
||||
import cascadetoml
|
||||
import pathlib
|
||||
|
@ -46,6 +47,18 @@ def main(input_template: pathlib.Path, output_path: pathlib.Path, skus: str = ty
|
|||
|
||||
max_clock_speed_mhz = min((x.get("max_clock_speed_mhz", 1000) for x in flashes["nvm"]))
|
||||
|
||||
default_power_of_two = None
|
||||
for nvm in flashes["nvm"]:
|
||||
capacity = nvm.get("capacity", 0)
|
||||
if not 21 <= capacity < 30:
|
||||
power_of_two = int(math.log2(nvm["total_size"]))
|
||||
if not default_power_of_two:
|
||||
default_power_of_two = power_of_two
|
||||
else:
|
||||
default_power_of_two = min(power_of_two, default_power_of_two)
|
||||
if not default_power_of_two:
|
||||
default_power_of_two = 21
|
||||
|
||||
# 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)
|
||||
|
@ -71,6 +84,7 @@ def main(input_template: pathlib.Path, output_path: pathlib.Path, skus: str = ty
|
|||
"clock_divider": clock_divider,
|
||||
"read_command": read_command,
|
||||
"wait_cycles": wait_cycles,
|
||||
"default_power_of_two": default_power_of_two,
|
||||
}
|
||||
|
||||
template = Template(input_template.read_text())
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "extmod/vfs.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
#include "genhdr/flash_info.h"
|
||||
#include "py/mphal.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
@ -68,7 +69,7 @@ void supervisor_flash_init(void) {
|
|||
uint8_t cmd[] = {0x9f, 0, 0, 0};
|
||||
uint8_t data[4];
|
||||
flash_do_cmd(cmd, data, 4);
|
||||
uint8_t power_of_two = 21;
|
||||
uint8_t power_of_two = FLASH_DEFAULT_POWER_OF_TWO;
|
||||
// Flash must be at least 2MB (1 << 21) because we use the first 1MB for the
|
||||
// CircuitPython core. We validate the range because Adesto Tech flash chips
|
||||
// don't return the correct value. So, we default to 2MB which will work for
|
||||
|
|
Loading…
Reference in New Issue