Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified build/bootloader_hi.bin
Binary file not shown.
2,705 changes: 1,356 additions & 1,349 deletions build/bootloader_hi.dump

Large diffs are not rendered by default.

Binary file modified build/bootloader_hi.elf
Binary file not shown.
Binary file modified build/bootloader_lo.elf
Binary file not shown.
Binary file modified build/kboot.kfpkg
Binary file not shown.
13 changes: 6 additions & 7 deletions src/bootloader_hi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ The following SPI Flash layout must be used when using **Kboot*

| From | To | Length | Comment |
| ---: | ---: | ---: | :--- |
| `0x00000000` | `0x0000FFFF` | 64K | **Kboot** application code |
| `0x00010000` | `0x0001FFFF` | 64K | reserved for future use |
| `0x00020000` | `0x00020FFF` | 4K | main **boot configuration** sector |
| `0x00021000` | `0x00021FFF` | 4K | backup **boot configuration** sector |
| `0x00022000` | `0x0002FFFF` | 56K | reserved, user data etc. |
| `0x00030000` | `0x0007FFFF` | 320K | **default application** code |
| `0x00080000` | `Flash end` | --- | user area, application(s) code, file system(s), user data etc. |
| `0x00000000` | `0x00003FFF` | 64K | **Kboot** application code |
| `0x00004000` | `0x00004FFF` | 4K | main **boot configuration** sector |
| `0x00005000` | `0x00005FFF` | 4K | backup **boot configuration** sector |
| `0x00006000` | `0x0000FFFF` | 40K | reserved |
| `0x00010000` | `DEF_END` | --- | **default application** code |
| `DEF_END` | `Flash end` | --- | user area, application(s) code, file system(s), user data etc. |

<br>

Expand Down
22 changes: 13 additions & 9 deletions src/bootloader_hi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static uint32_t *cfg_flash_ptr = (uint32_t *)(SPI3_BASE_ADDR+BOOT_CONFIG_ADDR);
static uint8_t *cfg_flash_bptr = (uint8_t *)(SPI3_BASE_ADDR+BOOT_CONFIG_ADDR);

static uint32_t i = 0;
static uint32_t boot_entry = 0;
static uint32_t cfg_offset = 0;
static uint32_t offset = 0;
static uint8_t key = 0;
Expand Down Expand Up @@ -341,7 +342,7 @@ int main(void)
boot_pin = gpiohs_get_pin(GPIO_KEY);
}

LOG("\nK210 bootloader by LoBo v.1.4.1\n\n");
LOG("\nK210 bootloader by LoBo v.1.4.2\n\n");

LOG("* Find applications in MAIN parameters\n");

Expand All @@ -365,9 +366,9 @@ int main(void)
// Valid size
LOG("@ 0x%08X, size=%u, ", cfg_address, cfg_size);
/*
* Basic check passed, now we can check the application's vilidity
* Basic check passed, now we can check the application's validity
* If in interractive mode, all applications are checked,
* otherwize, the application is checked only if flagged as active
* otherwise, the application is checked only if flagged as active
*/
if ((cfg_magic & CFG_APP_FLAG_ACTIVE) || (boot_pin == 0)) {
// ** Check if valid application
Expand All @@ -391,7 +392,7 @@ int main(void)
app_flash_start = cfg_address;
}
if (boot_pin > 0) {
// Active application found and cheched and not in interractive mode
// Active application found and checked and not in interractive mode
LOG("ACTIVE\n");
break;
}
Expand All @@ -409,10 +410,10 @@ int main(void)
}

// check if any valid application was found
for (i = 0; i < BOOT_CONFIG_ITEMS; i++) {
if (available_apps[i]) break;
for (boot_entry = 0; boot_entry < BOOT_CONFIG_ITEMS; boot_entry++) {
if (available_apps[boot_entry]) break;
}
if ((app_flash_start == DEFAULT_APP_ADDR) && (i >= BOOT_CONFIG_ITEMS)) {
if ((app_flash_start == DEFAULT_APP_ADDR) && (boot_entry >= BOOT_CONFIG_ITEMS)) {
// No valid application found
if (cfg_offset == 0) {
// no valid entry found in main config sector, check the backup one
Expand Down Expand Up @@ -456,6 +457,7 @@ int main(void)
// get application's size and address in Flash
app_size = flash2uint32(cfg_address+1);
app_flash_start = cfg_address;
boot_entry = char_in;
char_in += 0x30;
break;
}
Expand All @@ -475,8 +477,10 @@ int main(void)
if ((app_size >= MIN_APP_FLASH_SIZE) && (app_size <= MAX_APP_FLASH_SIZE)) {
cfg_size = app_size;
cfg_address = app_flash_start;
// Check default application
if (app_sha256()) key = 0;
// Check default application if no app selected
if ((boot_entry < BOOT_CONFIG_ITEMS) || app_sha256()) {
key = 0;
}
}
if (key) {
// Check failed
Expand Down