Giovanni,
In a project that I started AFTER 3.0 came out, I now have compilation errors. Some ASM sources were renamed from .s to .S, and that required a change in the Makefile.
Some startup files were moved. So that requires a change in the Makefile.
Similarly, I tried "porting" the F103 FATFS demo to my '103. The complexity of everything caused me to spend hours trying to get it to work before I found out that my '103 CPU doesn't have SPI2.
Then I tried porting it to my 072 board. That resulted in lots of problems because of '103 related things in the Makefile. (e.g. armV6 vs armV7 startup files)
If the Makefile could just be BOARD=<someboard> (which has a default CPU) and that I can then add CPU=STM32F103R6 to my Makefile to compile for a different CPU on the same board, then things would have much simpler to try and port this. Then I would have immediately gotten a "your CPU doesn't have SPI2" error. Now I changed the minimal things, knowing the cpu WAS and REMAINED a '103, to make it work. Of course thinking that STM32F103R6 is almost the same as the STM32F103R8 on the board I was cloning is a mistake that can still happen. But with just ONE thing to change, the chance for errors becomes a lot smaller.
Maybe I'm exagerating a bit. But IMHO for the success of Chibios to improve, I think it would be a useful idea to try and put my sample source and sample Makefile in a "demo" subdirectory, and then make it work. At first the Makefile will just include a chibios-rules file that is in that same directory. Then we should try to make another demo work with a very similar "small" makefile, using the same "generic" makefile. Once that works, we can consider integrating it into Chibios.
I might even be persuaded to provide patches. But then you have to be "on board" that they will go into the main Chibios. Of course just changing the makefile, and using diff to figure out the differences is at each point in time faster and easier than in rewriting the whole thing to do it better.....
About "halconf" generating documentation... I honestly do not see the value of documenting
Code: Select all
HAL_USE_SPI enable the HAL SPI module
HAL_USE_DAC enable the HAL DAC module
HAL_USE_UART enable the HAL UART module
etc.
There needs to be an actual documentation there. Something that the code not already says. The classic example is a beginning programmer who documents:
Granted, for someone doing their first baby steps in the "C" language that might be a reminder for how "increment i" is written in C. But for the most of us the documentation at that level is useless. Similarly to me a lot of chibios documentation is useless. Here HAL_USE_UART tells me exactly the same thing as "enable the HAL UART module". Similarly I scrolled to a random page somewhere in the middle of the HAL documentation. I find:
Code: Select all
static bool sdc_init(SDCDriver *sdcp) [static]
Parameters:
in | sdcp | pointer to the SDCDriver object
What does this document? Reading the prototype, I can see that the function is static. (the "[static]" is redundant), and the rest of the declaration tells me that there is a parameter called sdcp that is a pointer to an SDCDriver object. Again, this is documentation that might remind a "first week of C" programmer as to what that definition does, but it does not help someone with more than a month of C-experience in how to use this function.
About the mcuconf file being CPU dependent, there should be enough defaults to make an empty one work.
That might mean that the "central" mcuconf file does something like:
Code: Select all
#if CPU == STM32F103x6
#include "mcuconf_103x6.h"
#else
...
#endif
And that suitable defautls are used:
[/code]
#if defined (HAL_USE_SPI) AND !defined( MCU_USE_SPI1) && !defined (MCU_USE_SPI2) && ...
#define MCU_USE_SPI1
#endif[/code]This will allow you to turn on SPI and by default it will enable SPI1. If you want to make it explicit, or if you want to use another SPI module, just #define MCU_USE_SPIx in the "small" mcuconf.h file.
Similarly, I would want Chibios to help me find a DMA channel for my module. On STM32F4 I can simply select a channel, but on STM32F0 there is no choice. So, for the rest of CHIBIOS, the not-really-a-choice of the DMA channel on F0 should be somewhere central, and not in MY mcuconf.h. And for F4, a default would be provided that tries to prevent common clashes, but may need configuration by the user if the situation gets complicated.
Try to imagine 10 users using SPI on an F4 discovery board. Which SPI module are they going to use, what DMA channels are they assigning?