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

serial_nor complex driver should return status

Postby faisal » Fri Nov 05, 2021 5:37 pm

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: serial_nor complex driver should return status

Postby Giovanni » Fri Nov 05, 2021 5:46 pm

Hi,

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

Giovanni

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: serial_nor complex driver should return status

Postby faisal » Fri Nov 05, 2021 6:04 pm

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: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: serial_nor complex driver should return status

Postby faisal » Fri Nov 05, 2021 6:09 pm

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: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: serial_nor complex driver should return status

Postby faisal » Fri Nov 05, 2021 6:17 pm

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


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 13 guests