Skip to content

Commit

Permalink
[Ion/slots] Fix slot detection and persisting bytes location
Browse files Browse the repository at this point in the history
  • Loading branch information
RedGl0w committed Sep 13, 2021
1 parent cc46c1d commit 4fb36ce
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ion/src/device/kernel/shared_kernel_flash.ld
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PERSITING_BYTES_ORIGIN = PERSITING_BYTES_VIRTUAL_ORIGIN + EPSILON_OFFSET;
PERSITING_BYTES_ORIGIN = PERSITING_BYTES_VIRTUAL_ORIGIN + EPSILON_SLOT * PERSITING_BYTES_LENGTH;
KERNEL_ORIGIN = KERNEL_VIRTUAL_ORIGIN + EPSILON_OFFSET;

MEMORY {
Expand Down
6 changes: 3 additions & 3 deletions ion/src/device/n0110/kernel/drivers/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,14 @@ void shutdownPeripheralsClocks(bool keepLEDAwake) {
}

bool isRunningSlotA() {
return reinterpret_cast<uint32_t>(&_isr_vector_table_start_flash) < ExternalFlash::Config::StartAddress + ExternalFlash::Config::TotalSize/2;
return reinterpret_cast<uint32_t>(&_isr_vector_table_start_flash) < ExternalFlash::Config::StartAddress + 1024*1024;
}

bool isInReflashableSector(uint32_t address) {
if (isRunningSlotA()) {
return address >= ExternalFlash::Config::StartAddress + ExternalFlash::Config::TotalSize/2 && address < ExternalFlash::Config::EndAddress;
return address >= ExternalFlash::Config::StartAddress + 1024*1024 && address < ExternalFlash::Config::EndAddress;
}
return address >= ExternalFlash::Config::StartAddress && address < ExternalFlash::Config::StartAddress + ExternalFlash::Config::TotalSize/2;
return address >= ExternalFlash::Config::StartAddress && address < ExternalFlash::Config::StartAddress + 1024*1024;
}

void switchExecutableSlot(uint32_t leaveAddress) {
Expand Down
2 changes: 1 addition & 1 deletion ion/src/device/n0110/shared/config_flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EXTERNAL_FLASH_ORIGIN = 0x90000000;
EXTERNAL_FLASH_LENGTH = 8M;
STANDARD_EXTERNAL_FLASH_SECTOR_LENGTH = 64K;

PERSITING_BYTES_VIRTUAL_ORIGIN = EXTERNAL_FLASH_ORIGIN + EXTERNAL_FLASH_LENGTH / 2 - STANDARD_EXTERNAL_FLASH_SECTOR_LENGTH;
PERSITING_BYTES_VIRTUAL_ORIGIN = EXTERNAL_FLASH_ORIGIN + EXTERNAL_FLASH_LENGTH - 2 * STANDARD_EXTERNAL_FLASH_SECTOR_LENGTH;
PERSITING_BYTES_LENGTH = STANDARD_EXTERNAL_FLASH_SECTOR_LENGTH;

KERNEL_VIRTUAL_ORIGIN = EXTERNAL_FLASH_ORIGIN;
Expand Down
1 change: 1 addition & 0 deletions ion/src/device/n0110/shared/config_slot_a.ld
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
EPSILON_OFFSET = 0;
EPSILON_SLOT = 0;
1 change: 1 addition & 0 deletions ion/src/device/n0110/shared/config_slot_b.ld
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
EPSILON_OFFSET = 1M;
EPSILON_SLOT = 1;
2 changes: 1 addition & 1 deletion ion/src/device/n0110/shared/drivers/config/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ constexpr static uint32_t BootloaderTrampolineAddress = BootloaderStartAddress +

// Slots
constexpr static uint32_t SlotAStartAddress = ExternalFlash::Config::StartAddress;
constexpr static uint32_t SlotBStartAddress = ExternalFlash::Config::StartAddress + ExternalFlash::Config::TotalSize/2;
constexpr static uint32_t SlotBStartAddress = ExternalFlash::Config::StartAddress + 1024*1024;

// Kernel
constexpr static uint32_t KernelSize = 0x10000; // 64kB
Expand Down

0 comments on commit 4fb36ce

Please sign in to comment.