Re: NUCLEO-F746ZG - ChibiOS is great!
Posted: Tue Apr 19, 2016 12:16 pm
Hi, last weekend I have created board files for some new Nucleo144 included the F746ZG. They are on trunk. Enjoy!
ChibiOS Web Boards
https://forum.chibios.org/
Would it be an idea to create "generic" board file examples? i.e. board files that are completely empty except for the necessary defines?
RoccoMarco wrote:There is a lot of documentation about that. I think is not a good idea to create new code (which must be maintained over time) just to explain a mechanism that actually is well explained into documentation.
Code: Select all
/*
* Board oscillators-related settings.
* NOTE: LSE not fitted.
* NOTE: HSE not fitted.
*/
#if !defined(STM32_LSECLK)
#define STM32_LSECLK 0U
#endif
#if !defined(STM32_HSECLK)
#define STM32_HSECLK 0U
#endif
Code: Select all
#define GPIOA_PIN6 6U
#define GPIOA_PIN7 7U
#define GPIOA_PIN8 8U
#define GPIOA_PIN9 9U
#define GPIOA_PIN10 10U
Code: Select all
#define PIN_MODE_INPUT(n) (0U << ((n) * 2U))
#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U))
To be honest, when I started with ChibiOS I did not even know the existence of documentation, neither was interested in (booOOOooring). Actually, getting started requires just few knowledge of C, a bit of "dexterity" and existing demos. But if you want to understand how mechanisms work the documentation is of major importance.
rew wrote:If you want to reduce the copied-a-million-times code that now has to be maintained in many places you can start with board.h
rew wrote:Why not use a post-board.h-include that does this? Many boards have this: we don't have crystals mounted.
rew wrote:Moreover, in mcuconf.h you can chose to enable the external clock. But the crystal specification is here. They should be in one place. I've been running off internal RC before I went in and enabled the external clock. Then all of a sudden I find this doesn't work-by-default define in a totally different place.
rew wrote:What use is it to write GPIOA_PIN7 instead of "7" in the PalSetPinMode (GPIOA, ... call?
rew wrote:Why does this have to be duplicated for each board? This depends on the processor family and maybe there are a few exceptions, but why not centrally somewhere for STM boards? Actually I just checked. This code is present in 20 board.h files. There are 30 STM32 boards... I'm guessing there is a copy-paste maintenance problem here....
rew wrote:I don't know about you, but each time I need documentation for chibios, I get a dead end. When I want to now say "strstr" in php, I google for "strstr php" and I get THE manual for strstr in php. It explains what it is for, it explains that there are a bunch of arguments and what these arguments do.
For chibios, once I know the function name, or maybe hal subsystem, I google for "chibios <keyword>" and get a hit for the 2.6.6 documentation. You have to be aware of that version number, because at first you don't realize that you're looking at old documentation. There you find a big listing with the names of the functions (I could have grepped the source for that) with the names of the arguments (I could have grepped the source for that) and... nothing more. No explanation of what those arguments do, or when to call that function. Yeah. there is a "state diagram". It tells me the driver needs to be initialized before I can use it. But then it doesn't tell me that I need to call that or if it will be done for me. From the driver's point of view, it's all clear ("Of course the driver needs to be initialized!"), but from the user it is not.
Yeah. there is documentation. But noting "usable".
So why, when I have my own board, do I end up copying and editing the board.h?RoccoMarco wrote:rew wrote:If you want to reduce the copied-a-million-times code that now has to be maintained in many places you can start with board.h
We don't copy this code million of time. It is auto-generated. There is a video in the post i linked before that show this.
rew wrote:So why, when I have my own board, do I end up copying and editing the board.h?
rew wrote:So then I follow the compilation process of my project, find the board file I have been using all along, copy it into a subdirectory of my project and start changing it. If it is a generated file, I expect it to start with " /* This file is generated from ... by tool-X DO NOT EDIT */" but instead it starts with the standard source-code-copyright claim
rew wrote:In technical situations, sometimes the "bottom-up" way of thinking leads to one situation, while top down would lead to another way of organizing. Bottom-up dictates that indeed the external crystal frequency be specified at the board level and not in mcuconf. But why isn't there a "if you enable external clock here, don't forget to set the crystal frequency in board.h!" in mcuconf? it cost me countless hours to figure that one out.
rew wrote:Your preferred way of structuring things is not applicable to all situations. In your case, the board always defines what hardware is on it, like crystal, CPU and other hardware. I have a bunch of boards that can have many different CPUs and any crystal I like (OK, as to crystal I limit myself to none or 8MHz).