Evaluating ChibiOS/HAL

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
GeneM
Posts: 2
Joined: Sun Jun 19, 2022 4:22 pm

Evaluating ChibiOS/HAL

Postby GeneM » Thu Jun 23, 2022 3:40 pm

Hi - ChibiOS/HAL and other Chibi tools may be a really good solution for a new app I'm working on and I have a few questions before I dive in. Here's some background. I'm porting a medium size (12000 lines or so) embedded program written in C# for a SAM9 processor to C/C++ and a STM32H7A3 controller. The program is architected as a pretty classic Gang Of Four state machine with asynchronous FIFO queues between the devices and the state machine. Currently, there are 8 different UART devices (GPS receiver, Iridium modem, oceanographic instruments, etc. ) and 3 I2C devices (voltage/current/energy monitors, ADCs, etc.) with more in the future, so lots of I/O. Coming from the C# world, I'm a big fan of an object oriented architecture. I have the core part of my program running on a ST Micro Nucleo H7A3ZIQ development board using VisualGDB and the ST Micro HAL library.

It was quite a struggle to get the STM HAL library working in an OO architecture and at first glance, the ChibiOS/HAL seems like a much better architecture for an OO program. Here are a few new user type questions.

Q1) It would be nice to have a UART class with all the code required to communicate over a specific UART (drivers, IRQs, callback, etc.) that I can instantiate or inherit or something like that in each of my device classes. Is that a reasonable approach using ChibiOS/HAL? The same approach would apply to an I2C class, an SPI class and so on.
Q2) if a UART class isn't the way ChibiOS/HAL is designed to be used, what is the preferred approach? I've read the docs for the UART HAL driver and it may be that just a few lines of code and a callback function are required to use a UART. So no class is required, I just put those few lines of code in my device class?
Q3) I've gone through a couple of demos using ChibiStudio but haven't been able to download them to my H7A3 Nucleo board. What do I have to do to port an existing demo to work on my H7A3 Nucleo?
Q4) I use DMA where ever possible and the character match functionality on the H7A3 and in your UART driver seems like a great approach. Is there a UART demo using the CM functionality.

My goal here is to write a simple first program that talks to a GPS receiver over a UART using the CM functionality on my H7A3 Nucleo board. If I can get that working without too much effort, you'll have a new user.

Thanks in advance - Gene

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: Evaluating ChibiOS/HAL

Postby Giovanni » Thu Jun 23, 2022 5:15 pm

Hi,

Lots of questions :-)

About OO, HAL (and all the rest too) are written in an OO way just using C. Classes are structures, methods are functions that take the object as 1st parameter, virtual methods have a VMT (in classes with virtual methods), there are interfaces, inheritance (simple and multiple) etc etc. Functions like xxxObjectInit() are constructors. The rules are used across the whole codebase.

For example: streams -> channels -> asynchronous channels -> serial driver etc

Said that, it is possible to write C++ wrappers, there is a C++ wrapped for RT included, the same could be done for HAL but is it worth the effort? OO is matter of methodology not language.

The demo for your board is RT-STM32H7A3ZI_Q-NUCLEO144, note, it is present in version 21.11.2 or in trunk code. No need to port anything, compile and load the code on your board. The problem you may face is to find the appropriate OpenOCD configuration for your device.

See the guides on http://www.playembedded.org for ChibiStudio usage examples, join our discord server if you want quick help, I am mostly there over weekends and a little screen sharing is the quickest way.

viewtopic.php?f=3&t=5944

Giovanni

GeneM
Posts: 2
Joined: Sun Jun 19, 2022 4:22 pm

Re: Evaluating ChibiOS/HAL

Postby GeneM » Fri Jun 24, 2022 12:09 am

Thanks for the quick response. Some progress but 1 more question.

I downloaded ChibiOS/HAL 21.11.2 into my ChibiStudio folder. I found the RT-STM32H7ADZI_Q-Nucleo144 demo. It compiles and builds just fine. I can do this step from the "Developing on STM32: Introducing ChibiStudio" Article.

Build your target
in your project, under the folder build, select your elf file
From the External Tools Menu (Orange), choose “Create OpenOCD Debug Configuration (pre-select elf file into a project)” from the external tool menu


and I get this in the ChibiStudio Console window

Creating debug launch configurations for "build/ch.elf" ...

Done


But when I try to do the next step in the article:

Once the generation is done you can launch proceed with the flash and run. To do so we need to select again the External Tools Menu (Orange) and choose another launch configuration. When using the ST-Link as the interface you should pick up the script: “OpenOCD on ST-Link (prompts for .cfg target configuration)“. Note that, many OpenOCD configurations specify the interface internally and thus the script “OpenOCD no interface (prompts for .cfg target configuration)” will work as well.

I get a "Please input a value" window with 4 .launch file choices. I've tried all 4 and get this error in the Console window:

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
C:\ChibiStudio\ChibiOS_21.11.2\ChibiOS_21.11.2\demos\STM32\RT-STM32H7A3ZI_Q-NUCLEO144\debug\RT-STM32H7A3ZI_Q-NUCLEO144 (build-ch.elf)(OpenOCD, Flash and Run).launch:1: Error: invalid command name "<?xml"
in procedure 'script'
at file "embedded:startup.tcl", line 26
at file "C:\ChibiStudio\ChibiOS_21.11.2\ChibiOS_21.11.2\demos\STM32\RT-STM32H7A3ZI_Q-NUCLEO144\debug\RT-STM32H7A3ZI_Q-NUCLEO144 (build-ch.elf)(OpenOCD, Flash and Run).launch", line 1


Seems to me I should be looking for a .cfg file that's related to the STM32H7A3ZI_Q-Nucleo144 but I can't find it in the ChibiOS-21.11.2 folder or anywhere else. Clearly I'm doing something wrong. Any ideas what?

Thanks

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: Evaluating ChibiOS/HAL

Postby Giovanni » Fri Jun 24, 2022 5:01 am

When you launch OpenOCD it prompts you for an OpenOCD configuration file (not the .launch file just generated), files are under ./tools/openocd/scripts/board or ./tools/openocd/scripts/boards/target.

If I remember well you should use ./tools/openocd/scripts/boards/target/stm32h7x.cfg

This kind of things are explained in the OpenOCD documentation, OpenOCD is the FOSS GDB server used by ChibiStudio.

Giovanni


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 2 guests