diff --git a/src/board/system76/common/flash/main.c b/src/board/system76/common/flash/main.c index 58d0d6986..be84a864c 100644 --- a/src/board/system76/common/flash/main.c +++ b/src/board/system76/common/flash/main.c @@ -48,8 +48,8 @@ void flash_write_enable(void); */ void flash_entry(uint32_t addr, uint8_t *data, uint32_t length, uint8_t command) __reentrant __critical { - // Only allow access from 64KB to 128KB. - if ((addr < 0x10000) || (length > 0x10000) || ((addr + length) > 0x20000)) + // Only allow access from 64 KiB to the end of flash. + if ((addr < 0x10000) || (length > 0x10000) || ((addr + length) > CONFIG_EC_FLASH_SIZE)) return; if (command == FLASH_COMMAND_READ) { diff --git a/src/board/system76/common/keymap.c b/src/board/system76/common/keymap.c index 9fbc3db82..228388d8e 100644 --- a/src/board/system76/common/keymap.c +++ b/src/board/system76/common/keymap.c @@ -8,7 +8,7 @@ bool keymap_fnlock = false; uint16_t __xdata DYNAMIC_KEYMAP[KM_LAY][KM_OUT][KM_IN]; // Config is in the last sector of flash -const uint32_t CONFIG_ADDR = 0x1FC00; +const uint32_t CONFIG_ADDR = CONFIG_EC_FLASH_SIZE - 1024; // Signature is the size of the keymap const uint16_t CONFIG_SIGNATURE = sizeof(DYNAMIC_KEYMAP); diff --git a/src/ec/ite/ec.mk b/src/ec/ite/ec.mk index d61fa25ef..ce6b20411 100644 --- a/src/ec/ite/ec.mk +++ b/src/ec/ite/ec.mk @@ -45,3 +45,5 @@ CONFIG_EC_FLASH_SIZE = 262144 else $(error flash size not specified) endif + +CFLAGS += -DCONFIG_EC_FLASH_SIZE=$(CONFIG_EC_FLASH_SIZE)