Merge pull request #8297 from dhalbert/better-hard-fault-message

improve hard fault message
This commit is contained in:
Dan Halbert 2023-08-20 12:16:33 -04:00 committed by GitHub
commit 4593008317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 36 deletions

View File

@ -31,8 +31,8 @@ msgstr ""
#: supervisor/shared/safe_mode.c #: supervisor/shared/safe_mode.c
msgid "" msgid ""
"\n" "\n"
"Please file an issue with your program at https://github.com/adafruit/" "Please file an issue with your program at github.com/adafruit/circuitpython/"
"circuitpython/issues." "issues."
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c #: supervisor/shared/safe_mode.c
@ -182,6 +182,7 @@ msgid "%q must be 1 when %q is True"
msgstr "" msgstr ""
#: py/argcheck.c shared-bindings/gifio/GifWriter.c #: py/argcheck.c shared-bindings/gifio/GifWriter.c
#: shared-module/gifio/OnDiskGif.c
msgid "%q must be <= %d" msgid "%q must be <= %d"
msgstr "" msgstr ""
@ -632,11 +633,6 @@ msgstr ""
msgid "Buffer is not a bytearray." msgid "Buffer is not a bytearray."
msgstr "" msgstr ""
#: ports/cxd56/common-hal/camera/Camera.c shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Buffer is too small"
msgstr ""
#: ports/stm/common-hal/audiopwmio/PWMAudioOut.c #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c
#, c-format #, c-format
msgid "Buffer length %d too big. It must be less than %d" msgid "Buffer length %d too big. It must be less than %d"
@ -656,6 +652,12 @@ msgstr ""
msgid "Buffer too short by %d bytes" msgid "Buffer too short by %d bytes"
msgstr "" msgstr ""
#: ports/cxd56/common-hal/camera/Camera.c shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
#: shared-bindings/struct/__init__.c shared-module/struct/__init__.c
msgid "Buffer too small"
msgstr ""
#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c
msgid "Buffers must be same size" msgid "Buffers must be same size"
msgstr "" msgstr ""
@ -1006,10 +1008,6 @@ msgstr ""
msgid "Failed to write internal flash." msgid "Failed to write internal flash."
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c
msgid "Fault detected by hardware."
msgstr ""
#: py/moduerrno.c #: py/moduerrno.c
msgid "File exists" msgid "File exists"
msgstr "" msgstr ""
@ -1085,6 +1083,10 @@ msgstr ""
msgid "Half duplex SPI is not implemented" msgid "Half duplex SPI is not implemented"
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c
msgid "Hard fault: memory access or instruction error."
msgstr ""
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c
#: ports/stm/common-hal/sdioio/SDCard.c #: ports/stm/common-hal/sdioio/SDCard.c
@ -1785,6 +1787,10 @@ msgstr ""
msgid "Polygon needs at least 3 points" msgid "Polygon needs at least 3 points"
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c
msgid "Power dipped. Make sure you are providing enough power."
msgstr ""
#: shared-bindings/_bleio/Adapter.c #: shared-bindings/_bleio/Adapter.c
msgid "Prefix buffer must be on the heap" msgid "Prefix buffer must be on the heap"
msgstr "" msgstr ""
@ -1950,10 +1956,6 @@ msgstr ""
msgid "Size not supported" msgid "Size not supported"
msgstr "" msgstr ""
#: ports/raspberrypi/common-hal/alarm/SleepMemory.c
msgid "Sleep Memory not available"
msgstr ""
#: shared-bindings/alarm/SleepMemory.c shared-bindings/memorymap/AddressRange.c #: shared-bindings/alarm/SleepMemory.c shared-bindings/memorymap/AddressRange.c
#: shared-bindings/nvm/ByteArray.c #: shared-bindings/nvm/ByteArray.c
msgid "Slice and value different lengths." msgid "Slice and value different lengths."
@ -2019,10 +2021,6 @@ msgstr ""
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30" msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c
msgid "The power dipped. Make sure you are providing enough power."
msgstr ""
#: shared-module/audiomixer/MixerVoice.c #: shared-module/audiomixer/MixerVoice.c
msgid "The sample's bits_per_sample does not match the mixer's" msgid "The sample's bits_per_sample does not match the mixer's"
msgstr "" msgstr ""
@ -2608,8 +2606,7 @@ msgstr ""
msgid "buffer slices must be of equal length" msgid "buffer slices must be of equal length"
msgstr "" msgstr ""
#: py/modstruct.c shared-bindings/struct/__init__.c #: py/modstruct.c shared-module/struct/__init__.c
#: shared-module/struct/__init__.c
msgid "buffer too small" msgid "buffer too small"
msgstr "" msgstr ""
@ -3866,10 +3863,6 @@ msgstr ""
msgid "pixel coordinates out of bounds" msgid "pixel coordinates out of bounds"
msgstr "" msgstr ""
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter"
msgstr ""
#: extmod/vfs_posix_file.c #: extmod/vfs_posix_file.c
msgid "poll on file not available on win32" msgid "poll on file not available on win32"
msgstr "" msgstr ""

View File

@ -184,7 +184,7 @@ size_t common_hal_camera_take_picture(camera_obj_t *self, uint8_t *buffer, size_
mp_raise_ValueError(translate("Size not supported")); mp_raise_ValueError(translate("Size not supported"));
} }
if (!camera_check_buffer_length(width, height, format, len)) { if (!camera_check_buffer_length(width, height, format, len)) {
mp_raise_ValueError(translate("Buffer is too small")); mp_raise_ValueError(translate("Buffer too small"));
} }
if (!camera_check_format(format)) { if (!camera_check_format(format)) {
mp_raise_ValueError(translate("Format not supported")); mp_raise_ValueError(translate("Format not supported"));

View File

@ -506,7 +506,7 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po
displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); displayio_display_core_fill_area(&self->core, &area, mask, result_buffer);
return result; return result;
} else { } else {
mp_raise_ValueError(translate("Buffer is too small")); mp_raise_ValueError(translate("Buffer too small"));
} }
} }
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row); MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row);

View File

@ -351,7 +351,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_pixel_shader_obj, displayio_til
STATIC mp_obj_t displayio_tilegrid_obj_set_pixel_shader(mp_obj_t self_in, mp_obj_t pixel_shader) { STATIC mp_obj_t displayio_tilegrid_obj_set_pixel_shader(mp_obj_t self_in, mp_obj_t pixel_shader) {
displayio_tilegrid_t *self = native_tilegrid(self_in); displayio_tilegrid_t *self = native_tilegrid(self_in);
if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) { if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) {
mp_raise_TypeError(translate("pixel_shader must be displayio.Palette or displayio.ColorConverter")); mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);
} }
common_hal_displayio_tilegrid_set_pixel_shader(self, pixel_shader); common_hal_displayio_tilegrid_set_pixel_shader(self, pixel_shader);

View File

@ -317,7 +317,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_fill_row(size_t n_args, con
displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); displayio_display_core_fill_area(&self->core, &area, mask, result_buffer);
return result; return result;
} else { } else {
mp_raise_ValueError(translate("Buffer is too small")); mp_raise_ValueError(translate("Buffer too small"));
} }
} }
MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_fill_row_obj, 1, framebufferio_framebufferdisplay_obj_fill_row); MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_fill_row_obj, 1, framebufferio_framebufferdisplay_obj_fill_row);

View File

@ -92,7 +92,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
// negative offsets are relative to the end of the buffer // negative offsets are relative to the end of the buffer
offset = (mp_int_t)bufinfo.len + offset; offset = (mp_int_t)bufinfo.len + offset;
if (offset < 0) { if (offset < 0) {
mp_raise_RuntimeError(translate("buffer too small")); mp_raise_RuntimeError(translate("Buffer too small"));
} }
} }
byte *p = (byte *)bufinfo.buf; byte *p = (byte *)bufinfo.buf;
@ -151,7 +151,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_m
// negative offsets are relative to the end of the buffer // negative offsets are relative to the end of the buffer
offset = bufinfo.len + offset; offset = bufinfo.len + offset;
if (offset < 0) { if (offset < 0) {
mp_raise_RuntimeError(translate("buffer too small")); mp_raise_RuntimeError(translate("Buffer too small"));
} }
} }
p += offset; p += offset;

View File

@ -226,7 +226,7 @@ STATIC mp_obj_t vectorio_vector_shape_obj_set_pixel_shader(mp_obj_t wrapper_shap
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape)); vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) { if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) {
mp_raise_TypeError(translate("pixel_shader must be displayio.Palette or displayio.ColorConverter")); mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);
} }
common_hal_vectorio_vector_shape_set_pixel_shader(self, pixel_shader); common_hal_vectorio_vector_shape_set_pixel_shader(self, pixel_shader);

View File

@ -126,7 +126,7 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size
const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in); const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in);
if (p + total_sz > end_p) { if (p + total_sz > end_p) {
mp_raise_RuntimeError(translate("buffer too small")); mp_raise_RuntimeError(translate("Buffer too small"));
} }
size_t i = 0; size_t i = 0;

View File

@ -154,7 +154,7 @@ void print_safe_mode_message(safe_mode_t reason) {
switch (reason) { switch (reason) {
case SAFE_MODE_BROWNOUT: case SAFE_MODE_BROWNOUT:
message = translate("The power dipped. Make sure you are providing enough power."); message = translate("Power dipped. Make sure you are providing enough power.");
break; break;
case SAFE_MODE_USER: case SAFE_MODE_USER:
#if defined(BOARD_USER_SAFE_MODE_ACTION) #if defined(BOARD_USER_SAFE_MODE_ACTION)
@ -209,7 +209,7 @@ void print_safe_mode_message(safe_mode_t reason) {
message = translate("Failed to write internal flash."); message = translate("Failed to write internal flash.");
break; break;
case SAFE_MODE_HARD_FAULT: case SAFE_MODE_HARD_FAULT:
message = translate("Fault detected by hardware."); message = translate("Hard fault: memory access or instruction error.");
break; break;
case SAFE_MODE_INTERRUPT_ERROR: case SAFE_MODE_INTERRUPT_ERROR:
message = translate("Interrupt error."); message = translate("Interrupt error.");
@ -228,7 +228,7 @@ void print_safe_mode_message(safe_mode_t reason) {
break; break;
} }
serial_write_compressed(message); serial_write_compressed(message);
serial_write_compressed(translate("\nPlease file an issue with your program at https://github.com/adafruit/circuitpython/issues.")); serial_write_compressed(translate("\nPlease file an issue with your program at github.com/adafruit/circuitpython/issues."));
} }
// Always tell user how to get out of safe mode. // Always tell user how to get out of safe mode.