serial_nor complex driver should return status

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

serial_nor complex driver should return status

Post 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).
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: serial_nor complex driver should return status

Post by Giovanni »

Hi,

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

Giovanni
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

Re: serial_nor complex driver should return status

Post 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.
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

Re: serial_nor complex driver should return status

Post 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.
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

Re: serial_nor complex driver should return status

Post by faisal »

Also ... functions that call wspiCommand, wspiSend, wspiReceive should return status .. as those functions can fail.
Post Reply