Page 1 of 1

serial_nor complex driver should return status

Posted: Fri Nov 05, 2021 5:37 pm
by faisal
hal_serial_nor interacts with external peripherals, and validates responses and the such. In these circumstances, it should return with an error and allow the application code to remediate it (instead of solely relying upon asserts as is currently done in the flash device driver).

Solely relying upon asserts is fine for internal peripherals (though in Hi-Rel applications even that is not acceptable in most scenarios).

Re: serial_nor complex driver should return status

Posted: Fri Nov 05, 2021 5:46 pm
by Giovanni
Hi,

Which functions are you referring to? flashXXX() functions defined in the interface all return error codes.

Giovanni

Re: serial_nor complex driver should return status

Posted: Fri Nov 05, 2021 6:04 pm
by faisal
None of the hal_serial_nor exported functions return a status:
https://github.com/ChibiOS/ChibiOS/blob ... rial_nor.h

Here's an example:

snorStart() calls snor_device_init() which does a transaction with wspiReceive(). It then evaluates the response using an assert:

Code: Select all

  osalDbgAssert(n25q_find_id(n25q_manufacturer_ids,
                             sizeof n25q_manufacturer_ids,
                             devp->device_id[0]),
                "invalid manufacturer id");


The assert is fine, but it should also return, and errors should be propagated to the application code. Currently, neither snorStart() or snor_device_init() return anything.

Re: serial_nor complex driver should return status

Posted: Fri Nov 05, 2021 6:09 pm
by faisal
The example I gave may be the only one that actually doesn't return status lol :) As you pointed out, almost all other operations do return status.

Re: serial_nor complex driver should return status

Posted: Fri Nov 05, 2021 6:17 pm
by faisal
Also ... functions that call wspiCommand, wspiSend, wspiReceive should return status .. as those functions can fail.