Additional Simulator Posix HAL LLD drivers

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome.
yusuf.husainy
Posts: 7
Joined: Sat Jan 27, 2018 1:33 am
Has thanked: 4 times
Been thanked: 5 times

Additional Simulator Posix HAL LLD drivers

Postby yusuf.husainy » Thu Oct 18, 2018 6:58 pm

Hello,

We have developed/modified a few lld drivers to use in simulator posix environment taking inspiration from STM32:
1) HAL_CAN_LLD (Uses SocketCAN)
2) HAL_SERIAL_LLD (added TTY/PTS support)
3) HAL_UART_LLD (uses TTY/PTS)
4) HAL_RTC_LLD

Also added a "simulator_registry.h" for these peripherals.

Attached a patch for these changes.

A requirement for it:

Code: Select all

#define SIMULATOR_POSIX_MCUCONF
in mcuconf.h and,

Code: Select all

#define USE_SIM_SERIAL_TTY TRUE
in mcuconf.h if intending to use TTY/PTS for HAL_SERIAL or HAL_UART.

We would highly appreciate any feedback on the work. Any suggestions are welcome. If possible we can think to include it in trunk for next release?
Attachments
simulator_posix_hal_lld.zip
contains patch file for additional simulator posix LLD drivers
(27.95 KiB) Downloaded 18 times
Last edited by yusuf.husainy on Thu Oct 18, 2018 8:21 pm, edited 1 time in total.

User avatar
Giovanni
Site Admin
Posts: 11831
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 522 times
Been thanked: 433 times
Contact:

Re: Additional Simulator Posix HAL LLD drivers

Postby Giovanni » Thu Oct 18, 2018 7:30 pm

Hi,

It looks interesting, I cannot give it a try right now, too many things ongoing, I would appreciate some feedback about it.

It would help to know how to try it.

Giovanni

faisal
Posts: 242
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 35 times
Been thanked: 32 times

Re: Additional Simulator Posix HAL LLD drivers

Postby faisal » Thu Oct 18, 2018 10:46 pm

Giovanni wrote:Hi,

It looks interesting, I cannot give it a try right now, too many things ongoing, I would appreciate some feedback about it.

It would help to know how to try it.

Giovanni


It's pretty cool, we've been using it internally for a while now. So, it's battle tested code to some degree.

CAN: Using socket CAN allows you to connect multiple CAN nodes together (each of which could be a ChibiOS instance) on the same machine using vcan (virtual can devices - supported natively by socket CAN), or to external devices over an actual CAN device (such as a USB to CAN converter). It works transparently, and the ChibiOS application need not know if it is a virtual CAN device or a physical one. We've tested this using dozens of instances of ChibiOS running over multiple virtual CAN buses. The CAN buses were created using can-gw (in the linux can-utils package), which allows you to define routing rules between CAN devices. Using that tool, you can create multiple broadcast domains - thus making each one look like a "bus".

Serial/UART: Both of these use tty or pts in the back end. Which means, just like CAN, you can transparently have serial communication with a virtual tty device (pts) and communicate with another application on the same machine, or you can specify the path to /dev/ttyUSB0 for example - and do serial comms with a device external to the PC. The ChibiOS application doesn't really know the difference. The driver just needs a path to the device.

The UART driver is probably the one for which comments are needed. Currently it models the STM32 registers, as the existing HAL at the time didn't support character match - and we wanted our application to target both uC and simulation. This could probably use some working over...

I think improving the Simulation port of ChibiOS could lead to greater adoption as well - you don't even need hardware to evaluate it, and do quite complex things with it. For example, on each of those dozens of ChibiOS instances mentioned above, we were running a full IP stack, sensor emulation, file I/O, etc .. Each of which could be retargeted on actual hardware and pretty much "just work".

yusuf.husainy
Posts: 7
Joined: Sat Jan 27, 2018 1:33 am
Has thanked: 4 times
Been thanked: 5 times

Re: Additional Simulator Posix HAL LLD drivers

Postby yusuf.husainy » Sat Oct 20, 2018 12:30 am

Faisal has explained the overview well. Thanks :)

I have added following example projects with README that explains usage scenarios:

1) HAL_SERIAL_LLD : $(CHIBIOS)/demos/various/RT-Posix-Simulator
2) HAL_CAN_LLD : $(CHIBIOS)/testhal/simulator/posix/CAN
3) HAL_UART_LLD : $(CHIBIOS)/testhal/simulator/posix/UART
4) HAL_RTC_LLD : TODO, will add soon.

Find these examples and the drivers in the attached updated patch.
Attachments
simulator_posix_hal_lld.zip
Patch file for Simulator Posix Drivers and example projects with README's
(50.75 KiB) Downloaded 16 times

yusuf.husainy
Posts: 7
Joined: Sat Jan 27, 2018 1:33 am
Has thanked: 4 times
Been thanked: 5 times

Re: Additional Simulator Posix HAL LLD drivers

Postby yusuf.husainy » Tue Oct 23, 2018 8:32 pm

Hi,

I have attached the patch with HAL_RTC_LLD test example also. Please download this updated patch and experiment. It includes the drivers and the examples.

Test application locations:
1) HAL_SERIAL_LLD : $(CHIBIOS)/demos/various/RT-Posix-Simulator
2) HAL_CAN_LLD : $(CHIBIOS)/testhal/simulator/posix/CAN
3) HAL_UART_LLD : $(CHIBIOS)/testhal/simulator/posix/UART
4) HAL_RTC_LLD : $(CHIBIOS)/testhal/simulator/posix/RTC.
Attachments
simulator_posix_hal_lld.zip
Updated patch file with Driver code and test app code.
(56.13 KiB) Downloaded 20 times

faisal
Posts: 242
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 35 times
Been thanked: 32 times

Re: Additional Simulator Posix HAL LLD drivers

Postby faisal » Mon Dec 10, 2018 10:18 pm

It seems that you're nearing a release. Would like to know if you've had a chance to check this out and consider it for inclusion in ChibiOS/HAL. Increasing the coverage of the simulator is awesome for lots of people :) - especially if the simulator can use PC peripherals to talk to the outside world (as in the case of the CAN, UART, and Serial driver that has been contributed).

User avatar
Giovanni
Site Admin
Posts: 11831
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 522 times
Been thanked: 433 times
Contact:

Re: Additional Simulator Posix HAL LLD drivers

Postby Giovanni » Tue Dec 11, 2018 8:49 am

Forgot about this, too many things happening at same time...

Release is not that close anyway, I need to finalize all the changes.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 11831
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 522 times
Been thanked: 433 times
Contact:

Re: Additional Simulator Posix HAL LLD drivers

Postby Giovanni » Sun Dec 16, 2018 5:46 pm

Hi,

I tried this, it seems to break my testing procedures because differences in makefiles, the simulator is used for regression testing and code coverage so it is critical, in addition, coding style rules does not seem to be fully applied, I would appreciate an effort in this direction.

I will return on this at a later point.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests