Skip to content

Commit

Permalink
feat: add AT+OTA
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnL4 committed Jun 14, 2024
1 parent a86f676 commit ebb6449
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions porting/el_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class Device {

virtual void reset() = 0;

virtual void enter_bootloader() = 0;

const char* get_device_name() const { return _device_name; }
uint32_t get_device_id() const { return _device_id; }
uint32_t get_chip_revision_id() const { return _revision_id; }
Expand Down
11 changes: 10 additions & 1 deletion porting/himax/we2/el_device_we2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int _arm_npu_init(bool security_enable, bool privilege_enable) {
_arm_npu_irq_init();

/* Initialise Ethos-U55 device */
void* const ethosu_base_address = (void*)(U55_BASE);
void* const ethosu_base_address = (void*)(U55_BASE);

if (0 != (err = ethosu_init(&_ethosu_drv, /* Ethos-U driver device pointer */
ethosu_base_address, /* Ethos-U NPU's base address. */
Expand Down Expand Up @@ -171,6 +171,15 @@ void DeviceWE2::init() {

void DeviceWE2::reset() { __NVIC_SystemReset(); }

void DeviceWE2::enter_bootloader() {
el_printf("Enter bootloader\r\n");
hx_lib_spi_eeprom_enable_XIP(USE_DW_SPI_MST_Q, false, FLASH_QUAD, false);
hx_drv_scu_set_PB2_pinmux(SCU_PB2_PINMUX_SPI2AHB_DO, 1);
hx_drv_scu_set_PB3_pinmux(SCU_PB3_PINMUX_SPI2AHB_DI, 1);
hx_drv_scu_set_PB4_pinmux(SCU_PB4_PINMUX_SPI2AHB_SCLK, 1);
hx_drv_scu_set_PB5_pinmux(SCU_PB5_PINMUX_SPI2AHB_CS, 1);
}

Device* Device::get_device() {
static DeviceWE2 device{};
return &device;
Expand Down
2 changes: 2 additions & 0 deletions porting/himax/we2/el_device_we2.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class DeviceWE2 final : public Device {
void init();

void reset() override;

void enter_bootloader() override;
};

} // namespace edgelab
Expand Down
5 changes: 5 additions & 0 deletions sscma/main_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ void register_commands() {
[cmd = std::move(argv[0]), caller](const std::atomic<bool>&) { get_mqtt_pubsub(cmd, caller); });
return EL_OK;
});

static_resource->instance->register_cmd("OTA", "Enter OTA mode", "", [](std::vector<std::string>, void*) {
static_resource->executor->add_task([](const std::atomic<bool>&) { static_resource->device->enter_bootloader(); });
return EL_OK;
});
}

void wait_for_inputs() {
Expand Down

0 comments on commit ebb6449

Please sign in to comment.