Skip to content

Commit 55028d0

Browse files
committed
espulp: improve error messages
1 parent 660822a commit 55028d0

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

locale/circuitpython.pot

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ msgstr ""
11731173
msgid "Interrupted by output function"
11741174
msgstr ""
11751175

1176+
#: ports/espressif/common-hal/espulp/ULP.c
11761177
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
11771178
#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c
11781179
#: ports/raspberrypi/bindings/picodvi/Framebuffer.c
@@ -1240,10 +1241,6 @@ msgstr ""
12401241
msgid "Invalid multicast MAC address"
12411242
msgstr ""
12421243

1243-
#: ports/espressif/common-hal/espulp/ULP.c
1244-
msgid "Invalid parameters"
1245-
msgstr ""
1246-
12471244
#: ports/espressif/common-hal/espidf/__init__.c
12481245
msgid "Invalid size"
12491246
msgstr ""
@@ -1284,10 +1281,6 @@ msgstr ""
12841281
msgid "Layer must be a Group or TileGrid subclass"
12851282
msgstr ""
12861283

1287-
#: ports/espressif/common-hal/espulp/ULP.c
1288-
msgid "Load binary failed"
1289-
msgstr ""
1290-
12911284
#: ports/espressif/common-hal/espidf/__init__.c
12921285
msgid "MAC address was invalid"
12931286
msgstr ""
@@ -1834,10 +1827,6 @@ msgstr ""
18341827
msgid "Right format but not supported"
18351828
msgstr ""
18361829

1837-
#: ports/espressif/common-hal/espulp/ULP.c
1838-
msgid "Run binary failed"
1839-
msgstr ""
1840-
18411830
#: main.c
18421831
msgid "Running in safe mode! Not running saved code.\n"
18431832
msgstr ""

ports/espressif/common-hal/espulp/ULP.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "bindings/espulp/__init__.h"
88
#include "bindings/espulp/ULP.h"
9+
#include "bindings/espidf/__init__.h"
910

1011
#include "py/runtime.h"
1112
#include "shared-bindings/microcontroller/Pin.h"
@@ -37,10 +38,7 @@ void espulp_reset(void) {
3738
}
3839

3940
void common_hal_espulp_ulp_set_wakeup_period(espulp_ulp_obj_t *self, size_t period_index, uint32_t period_us) {
40-
int _errno = ulp_set_wakeup_period(period_index, period_us);
41-
if (_errno != ESP_OK) {
42-
mp_raise_ValueError(MP_ERROR_TEXT("Invalid parameters"));
43-
}
41+
CHECK_ESP_RESULT(ulp_set_wakeup_period(period_index, period_us));
4442
}
4543

4644
void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t length, uint32_t entry_point, uint32_t pin_mask) {
@@ -83,24 +81,24 @@ void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t
8381
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
8482
}
8583

86-
int _errno;
84+
esp_err_t result;
8785
switch (self->arch) {
8886
#ifdef CONFIG_ULP_COPROC_TYPE_FSM
8987
case FSM:
90-
_errno = ulp_load_binary(0, (const uint8_t *)program, length / sizeof(uint32_t));
91-
if (_errno != ESP_OK) {
92-
mp_raise_RuntimeError(MP_ERROR_TEXT("Load binary failed"));
93-
}
94-
_errno = ulp_run(entry_point / sizeof(uint32_t));
95-
if (_errno != ESP_OK) {
96-
mp_raise_RuntimeError(MP_ERROR_TEXT("Run binary failed"));
88+
result = ulp_load_binary(0, (const uint8_t *)program, length / sizeof(uint32_t));
89+
if (result != ESP_OK) {
90+
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_program);
9791
}
92+
CHECK_ESP_RESULT(ulp_run(entry_point / sizeof(uint32_t)));
9893
break;
9994
#endif
10095
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
10196
case RISCV:
102-
ulp_riscv_load_binary((const uint8_t *)program, length);
103-
ulp_riscv_run();
97+
result = ulp_riscv_load_binary((const uint8_t *)program, length);
98+
if (result != ESP_OK) {
99+
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_program);
100+
}
101+
CHECK_ESP_RESULT(ulp_riscv_run());
104102
break;
105103
#endif
106104
default:

0 commit comments

Comments
 (0)