Build epoch in info, flash-status command, cmake version embedding
This commit is contained in:
@@ -30,6 +30,11 @@ pico_generate_pio_header(picomap ${CMAKE_CURRENT_LIST_DIR}/w6300/qspi.pio)
|
||||
pico_enable_stdio_usb(picomap 0)
|
||||
pico_enable_stdio_uart(picomap 0)
|
||||
pico_set_binary_type(picomap copy_to_ram)
|
||||
string(TIMESTAMP BUILD_EPOCH "%s" UTC)
|
||||
math(EXPR VERSION_MAJOR "${BUILD_EPOCH} >> 16")
|
||||
math(EXPR VERSION_MINOR "${BUILD_EPOCH} & 65535")
|
||||
pico_set_binary_version(picomap MAJOR ${VERSION_MAJOR} MINOR ${VERSION_MINOR})
|
||||
target_compile_definitions(picomap PRIVATE BUILD_EPOCH=${BUILD_EPOCH})
|
||||
pico_add_extra_outputs(picomap)
|
||||
target_link_libraries(picomap ${LIB_DEPS})
|
||||
|
||||
@@ -40,5 +45,7 @@ pico_generate_pio_header(picomap_test ${CMAKE_CURRENT_LIST_DIR}/w6300/qspi.pio)
|
||||
pico_enable_stdio_usb(picomap_test 0)
|
||||
pico_enable_stdio_uart(picomap_test 0)
|
||||
pico_set_binary_type(picomap_test copy_to_ram)
|
||||
pico_set_binary_version(picomap_test MAJOR ${VERSION_MAJOR} MINOR ${VERSION_MINOR})
|
||||
target_compile_definitions(picomap_test PRIVATE BUILD_EPOCH=${BUILD_EPOCH})
|
||||
pico_add_extra_outputs(picomap_test)
|
||||
target_link_libraries(picomap_test ${LIB_DEPS})
|
||||
|
||||
@@ -10,6 +10,7 @@ static constexpr handler_entry handlers[] = {
|
||||
{RequestFlashErase::ext_id, typed_handler<RequestFlashErase, handle_flash_erase>},
|
||||
{RequestFlashWrite::ext_id, typed_handler<RequestFlashWrite, handle_flash_write>},
|
||||
{RequestReboot::ext_id, typed_handler<RequestReboot, handle_reboot>},
|
||||
{RequestFlashStatus::ext_id, typed_handler<RequestFlashStatus, handle_flash_status>},
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -14,3 +14,4 @@ std::optional<ResponseLog> handle_log(const responder& resp, const RequestLog&);
|
||||
std::optional<ResponseFlashErase> handle_flash_erase(const responder& resp, const RequestFlashErase&);
|
||||
std::optional<ResponseFlashWrite> handle_flash_write(const responder& resp, const RequestFlashWrite&);
|
||||
std::optional<ResponseReboot> handle_reboot(const responder& resp, const RequestReboot&);
|
||||
std::optional<ResponseFlashStatus> handle_flash_status(const responder& resp, const RequestFlashStatus&);
|
||||
|
||||
@@ -57,8 +57,9 @@ struct ResponseInfo {
|
||||
std::array<uint8_t, 4> ip;
|
||||
std::string firmware_name;
|
||||
boot_reason boot;
|
||||
auto as_tuple() const { return std::tie(board_id, mac, ip, firmware_name, boot); }
|
||||
auto as_tuple() { return std::tie(board_id, mac, ip, firmware_name, boot); }
|
||||
uint32_t build_epoch;
|
||||
auto as_tuple() const { return std::tie(board_id, mac, ip, firmware_name, boot, build_epoch); }
|
||||
auto as_tuple() { return std::tie(board_id, mac, ip, firmware_name, boot, build_epoch); }
|
||||
};
|
||||
|
||||
struct RequestLog {
|
||||
@@ -121,6 +122,20 @@ struct ResponseReboot {
|
||||
auto as_tuple() { return std::tie(); }
|
||||
};
|
||||
|
||||
struct RequestFlashStatus {
|
||||
static constexpr int8_t ext_id = 14;
|
||||
auto as_tuple() const { return std::tie(); }
|
||||
auto as_tuple() { return std::tie(); }
|
||||
};
|
||||
|
||||
struct ResponseFlashStatus {
|
||||
static constexpr int8_t ext_id = 15;
|
||||
int8_t boot_partition;
|
||||
uint8_t boot_type;
|
||||
auto as_tuple() const { return std::tie(boot_partition, boot_type); }
|
||||
auto as_tuple() { return std::tie(boot_partition, boot_type); }
|
||||
};
|
||||
|
||||
struct RequestListTests {
|
||||
static constexpr int8_t ext_id = 125;
|
||||
auto as_tuple() const { return std::tie(); }
|
||||
|
||||
@@ -45,6 +45,7 @@ std::optional<ResponseInfo> handle_info(const responder&, const RequestInfo&) {
|
||||
resp.ip = ns.ip;
|
||||
resp.firmware_name = firmware_name;
|
||||
resp.boot = detected_boot_reason;
|
||||
resp.build_epoch = BUILD_EPOCH;
|
||||
return resp;
|
||||
}
|
||||
|
||||
@@ -87,6 +88,19 @@ std::optional<ResponseFlashWrite> handle_flash_write(const responder&, const Req
|
||||
return ResponseFlashWrite{};
|
||||
}
|
||||
|
||||
std::optional<ResponseFlashStatus> handle_flash_status(const responder&, const RequestFlashStatus&) {
|
||||
ResponseFlashStatus resp;
|
||||
boot_info_t bi;
|
||||
if (rom_get_boot_info(&bi)) {
|
||||
resp.boot_partition = bi.partition;
|
||||
resp.boot_type = bi.boot_type;
|
||||
} else {
|
||||
resp.boot_partition = -1;
|
||||
resp.boot_type = 0;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
std::optional<ResponseReboot> handle_reboot(const responder&, const RequestReboot&) {
|
||||
dispatch_schedule_ms(100, []{
|
||||
watchdog_hw->scratch[0] = static_cast<uint32_t>(boot_reason::request_reboot);
|
||||
|
||||
@@ -20,6 +20,7 @@ static constexpr handler_entry handlers[] = {
|
||||
{RequestFlashErase::ext_id, typed_handler<RequestFlashErase, handle_flash_erase>},
|
||||
{RequestFlashWrite::ext_id, typed_handler<RequestFlashWrite, handle_flash_write>},
|
||||
{RequestReboot::ext_id, typed_handler<RequestReboot, handle_reboot>},
|
||||
{RequestFlashStatus::ext_id, typed_handler<RequestFlashStatus, handle_flash_status>},
|
||||
{RequestListTests::ext_id, typed_handler<RequestListTests, handle_list_tests>},
|
||||
{RequestTest::ext_id, typed_handler<RequestTest, handle_test>},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user