Skip to content

Commit

Permalink
[Ion/slots] Reduce slot size to 1M+500K, in order to have 5M for
Browse files Browse the repository at this point in the history
external apps
  • Loading branch information
RedGl0w committed Sep 15, 2021
1 parent 1af67fd commit 8bb1eb0
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
6 changes: 5 additions & 1 deletion ion/src/device/n0100/shared/config_flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ PERSITING_BYTES_VIRTUAL_ORIGIN = KERNEL_VIRTUAL_ORIGIN + KERNEL_LENGTH;
PERSITING_BYTES_LENGTH = SMALLEST_FLASH_SECTOR_LENGTH;

USERLAND_VIRTUAL_ORIGIN = PERSITING_BYTES_VIRTUAL_ORIGIN + PERSITING_BYTES_LENGTH;
USERLAND_AND_EXTERNAL_APPS_LENGTH = FLASH_LENGTH - PERSITING_BYTES_LENGTH - KERNEL_LENGTH;
USERLAND_LENGTH = FLASH_LENGTH - PERSITING_BYTES_LENGTH - KERNEL_LENGTH;

STORAGE_ORIGIN = FLASH_ORIGIN + FLASH_LENGTH;
STORAGE_SIZE = 0;


SIGNED_PAYLOAD_LENGTH = 0;
CANARY_LENGTH = 0;
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) < Board::Config::SlotBStartAddress;
}

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

void switchExecutableSlot(uint32_t leaveAddress) {
Expand Down
10 changes: 8 additions & 2 deletions ion/src/device/n0110/shared/config_flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ 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;
SLOT_SIZE = 1M+500K;

PERSITING_BYTES_VIRTUAL_ORIGIN = EXTERNAL_FLASH_ORIGIN + SLOT_SIZE - STANDARD_EXTERNAL_FLASH_SECTOR_LENGTH;
PERSITING_BYTES_LENGTH = STANDARD_EXTERNAL_FLASH_SECTOR_LENGTH;

KERNEL_VIRTUAL_ORIGIN = EXTERNAL_FLASH_ORIGIN;
KERNEL_LENGTH = 64K;

USERLAND_VIRTUAL_ORIGIN = KERNEL_VIRTUAL_ORIGIN + KERNEL_LENGTH;
USERLAND_AND_EXTERNAL_APPS_LENGTH = EXTERNAL_FLASH_LENGTH / 2 - KERNEL_LENGTH - PERSITING_BYTES_LENGTH;
USERLAND_LENGTH = SLOT_SIZE - PERSITING_BYTES_LENGTH - KERNEL_LENGTH;

STORAGE_ORIGIN = EXTERNAL_FLASH_ORIGIN + 2 * SLOT_SIZE;
STORAGE_SIZE = STORAGE_ORIGIN - EXTERNAL_FLASH_ORIGIN;


SIGNED_PAYLOAD_LENGTH = 8;
CANARY_LENGTH = 4;
Expand Down
2 changes: 1 addition & 1 deletion ion/src/device/n0110/shared/config_slot_b.ld
Original file line number Diff line number Diff line change
@@ -1 +1 @@
EPSILON_OFFSET = 4M;
EPSILON_OFFSET = 1M;
4 changes: 3 additions & 1 deletion ion/src/device/n0110/shared/drivers/config/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ constexpr static uint32_t BootloaderTrampolineSize = 0x2000; // 8k
constexpr static uint32_t BootloaderTrampolineAddress = BootloaderStartAddress + InternalFlash::Config::NumberOfSectors * BootloaderSectionSize - BootloaderTrampolineSize;

// Slots
constexpr static uint32_t SlotSize = 1536*1024; // 1M + 500K
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 + SlotSize;
constexpr static uint32_t StorageStartAdress = ExternalFlash::Config::StartAddress + 2 * SlotSize;

// Kernel
constexpr static uint32_t KernelSize = 0x10000; // 64kB
Expand Down
4 changes: 2 additions & 2 deletions ion/src/device/n0110/userland/drivers/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#include <shared/drivers/config/board.h>

extern "C" {
extern char _storage_flash_start;
extern char _data_section_start_flash;
}

namespace Ion {
namespace Device {
namespace Board {

bool isRunningSlotA() {
return reinterpret_cast<uint32_t>(&_storage_flash_start) < ExternalFlash::Config::StartAddress + ExternalFlash::Config::TotalSize/2;
return reinterpret_cast<uint32_t>(&_data_section_start_flash) < Board::Config::SlotBStartAddress;
}

}
Expand Down
2 changes: 1 addition & 1 deletion ion/src/device/n0110/userland/flash/storage.ld
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
. = ALIGN(64K);
_storage_flash_start = .;
. = (ORIGIN(FLASH_USERLAND) + LENGTH(FLASH_USERLAND));
. = (ORIGIN(STORAGE) + LENGTH(STORAGE));
_storage_flash_end = .;
5 changes: 3 additions & 2 deletions ion/src/device/userland/shared_userland_flash.ld
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
USERLAND_ORIGIN = USERLAND_VIRTUAL_ORIGIN + EPSILON_OFFSET;

MEMORY {
FLASH_USERLAND (rx) : ORIGIN = USERLAND_ORIGIN, LENGTH = USERLAND_AND_EXTERNAL_APPS_LENGTH
FLASH_USERLAND (rx) : ORIGIN = USERLAND_ORIGIN, LENGTH = USERLAND_LENGTH
STORAGE (rx) : ORIGIN = STORAGE_ORIGIN, LENGTH = STORAGE_SIZE
SRAM (rw) : ORIGIN = USERLAND_SRAM_ORIGIN, LENGTH = USERLAND_SRAM_LENGTH
}

Expand Down Expand Up @@ -65,7 +66,7 @@ SECTIONS {

.storage_flash : {
INCLUDE flash/storage.ld
} >FLASH_USERLAND
} >STORAGE

.bss : {
/* The bss section contains data for all uninitialized variables
Expand Down

0 comments on commit 8bb1eb0

Please sign in to comment.