Skip to content

Commit

Permalink
Save dynamic keymap at last sector
Browse files Browse the repository at this point in the history
With the use of 256 KiB flash chips, the hard-coded address of 0x1FC00
may no longer be "the last sector".

Signed-off-by: Tim Crawford <tcrawford@system76.com>
  • Loading branch information
crawfxrd committed Aug 23, 2024
1 parent 2925376 commit 1232716
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/board/system76/common/flash/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/board/system76/common/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/ec/ite/ec.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 1232716

Please sign in to comment.