New method for determining active partition

master
Ralf Schlatterbeck 2017-08-22 20:20:07 +02:00
parent 406fb7ea44
commit cc48b88713
5 changed files with 11 additions and 13 deletions

View File

@ -158,7 +158,7 @@ GENERIC_RESOURCE
);
static size_t
get_callers_part
get_active_part
( const char *name
, const char *uri
, const char *query
@ -166,16 +166,16 @@ get_callers_part
, size_t bsize
)
{
return snprintf (buf, bsize, "%ld", bootloader_get_callers_part ());
return snprintf (buf, bsize, "%ld", bootloader_get_active_part ());
}
GENERIC_RESOURCE
( callers_part
, Currently booted partition
( active_part
, Currently active partition
, count
, 0
, NULL
, get_callers_part
, get_active_part
);
/*
@ -202,9 +202,8 @@ get_part_start
)
{
int idx = get_query_partition (query);
printf ("part: %d", idx);
if (idx < 0) {
return snprintf (buf, bsize, "Invalid: %s", query);
return snprintf (buf, bsize, "Invalid: \"%s\" use part=N query", query);
}
return snprintf (buf, bsize, "%ld", bootloader_get_part_start (idx));
}
@ -224,7 +223,6 @@ set_part_ok
{
uint32_t tmp = strtoul (s, NULL, 10);
int idx = get_query_partition (query);
printf ("part: %d", idx);
if (idx < 0) {
return -1;
}

View File

@ -3,6 +3,6 @@ extern resource_t res_part_count;
extern resource_t res_part_size;
extern resource_t res_boot_default;
extern resource_t res_boot_next;
extern resource_t res_callers_part;
extern resource_t res_active_part;
extern resource_t res_part_start;
extern resource_t res_part_ok;

View File

@ -24,7 +24,7 @@ void setup (void)
rest_activate_resource (&res_part_size, (char *)"part_size");
rest_activate_resource (&res_boot_default, (char *)"boot_default");
rest_activate_resource (&res_boot_next, (char *)"boot_next");
rest_activate_resource (&res_callers_part, (char *)"callers_part");
rest_activate_resource (&res_active_part, (char *)"active_part");
rest_activate_resource (&res_part_start, (char *)"part_start");
rest_activate_resource (&res_part_ok, (char *)"part_ok");
}

View File

@ -91,7 +91,7 @@ BOOTLOADER_SET_BOOT_NEXT=0x0003ffa0
BOOTLOADER_BACKUP_IRQ_TABLE=0x0003ffa4
BOOTLOADER_GET_BOOT_DEFAULT=0x0003ffa8
BOOTLOADER_GET_BOOT_NEXT=0x0003ffac
BOOTLOADER_GET_CALLERS_PART=0x0003ffb0
BOOTLOADER_GET_ACTIVE_PART=0x0003ffb0
BOOTLOADER_PARTITION=0
TEXT_SECTION_LENGTH=0x1ef00
@ -122,7 +122,7 @@ LDFLAGS += -Wl,--defsym,bootloader_get_mac=$(BOOTLOADER_GET_MAC) \
-Wl,--defsym,_bootloader_backup_irq_table=$(BOOTLOADER_BACKUP_IRQ_TABLE) \
-Wl,--defsym,bootloader_get_boot_default=$(BOOTLOADER_GET_BOOT_DEFAULT) \
-Wl,--defsym,bootloader_get_boot_next=$(BOOTLOADER_GET_BOOT_NEXT) \
-Wl,--defsym,bootloader_get_callers_part=$(BOOTLOADER_GET_CALLERS_PART) \
-Wl,--defsym,bootloader_get_active_part=$(BOOTLOADER_GET_ACTIVE_PART) \
-Wl,--defsym,__TEXT_SECTION_OFFSET__=$(TEXT_SECTION_START) \
-T $(THISPLATFORM)/custom-avr6.xm

View File

@ -7,7 +7,7 @@ extern uint32_t bootloader_get_part_size (void);
extern uint32_t bootloader_get_part_start (uint32_t part_index);
extern uint32_t bootloader_get_boot_default (void);
extern uint32_t bootloader_get_boot_next (void);
extern uint32_t bootloader_get_callers_part (void);
extern uint32_t bootloader_get_active_part (void);
/* These write to flash and need to turn off interrupts before start */
extern void _bootloader_set_part_ok (uint32_t part_index);