-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for STM32F2 #33
base: master
Are you sure you want to change the base?
Conversation
svhelper
commented
Sep 1, 2018
- Added support for STM32F2
- Added example board based on STM32F205RE with crystal 16MHz
- All can be compiled manually or by the build system (web-site)
Hi, Looks like most of the HAL code was copied from the F4 code and just minor adaptations were made. I'm not comfortable merging this because this means I need to maintain mostly duplicated code. I rather think the existing code should be modified to support F2 as well. It may have been a mistake to name the things "Stm32f4" in the first place but that is a minor concern. By the way, do you indeed use the SD/SDIO code? |
Hi, Yes, the HAL has been copied due to most of periphery has the same features. I was not sure about your preferences for making changes to your code by third-party developers, but now all clear - you should not merge this code, but simple use "Stm32" for full ST family line. And yes - I use this SD/SDIO without any changes - the F2 and F4 has different cores Cortex M3 and M4, but the same periphery and their features (like DMA). By the way, if you d'like to replase Stm32f4 with Stm32, I think you should also make simple adjustment of system clock - just now the core clock, bus clocks (periphery), PLL and so, made as board specific. That make impossible to change MCU not between family lines, but even with in single family line. Can you also export from board script to the web interface (json file) at least the following:
If I can help you to improve this project, please touch me feel free. PS: my the next steps - as additional storage, like SD, I going to add support of USB host (MSC over USB-FS, can provide speed up to 1 MBytes that should enough for most of projects). And then add TFT display over serial interface (initially SPI, then may be I will add parallel), but this is another story. Sorry for my English |
Thanks for the explanation. About the board scripts, they are a remnant from time time ago and ideally all would be configurable via the "board" section in the configurator. I'm closing this since I don't want to merge it as is. I may be able to incorporate F2 support based on this when I find time for this, together with improvements to make more things configurable in "board" settings and remove the "board scripts". |
Hi, I apologize for returning to this issue. Is it OK, if I will try to make common STM32/GD32 drivers for already supported devices as separate configuration? Best regards, |
Sure that would be great if you try to merge this code. I am mostly concerned about the "real" code in the hal/ directory that I wrote. You can rename from Stm32F4Something to Stm32FSomething and adapt the generate.py script. Using preprocessor checks to see which CPU is used is fine. Don't forget that existing config files for F4 should keep working, so don't do the same thing for the config file structure. |
Hi, The next my steps - moving hard coded board declarations to the board section of configurator. If you have some comments, please leave them. br, |
Hi, I can create merge request for applying of those changes to your branch. Now I can continue to refactor other low-level and middle layers drivers (like USBD and SDIO) to remove dependencies from Stm32CubeMX (for F4 its weight about 400MB) br, |
Hi, I have the following comments/questions.
When the above issues are addressed I will do some sanity tests with my boards, if everything is fine I will then merge. |
Please ignore this I later saw the use for GPIO. |
Hi, Please find below my answers on your comments and questions.
This macros should works on all GNU compilers (include clang). But it has small issue - it returns "1" when no arguments has been passed to it.
Ignored ;)
It used during check at compilation time (in static_assert), so it should not be a problem.
If you compare all startup files for F2 and F4, you may observe that main differense:
So, this single startup file may be used for both of lines - F2 and F4
The current state of branch - using of F4 HAL as reference, because switching between HALs required large number of changes.
This is very interesting change - very simple, but very difficult.
So, in this fix, I simple rollback the driver type (from "composite usb-device" to "virtual comport"), beacuse it make compatibility with previous Win OS. Looks like in the near future you are not going to add access to sd-card via USB (U-disk/mass storage etc), so this fix should be OK.
For modules, that used in APrinter, it's OK.
You right, it will be more flexible.
You are right - the last commit removes necessary in it.
This is my omission also.
This merge request refs to the "master" branch, but my changes created in "STM32 common". I hope, my answers is clear for you (due to my poor English, where Google translate may give me odds) br, |
I double checked my changes and I became very surprised - with gcc 7.3 (i.e. on aprinter environment) this fix does not worked. The feature with deleting of comma |
Hi, Sorry for ask there.
Another question - what reason to not use the DMA with the SDIO module? br, |
Thanks for the informative answers. Yes please open a pull request with what you think I should merge, and I will give it a bit of sanity testing, to check that platforms I have still compile and work.
Please check the long comment just below the declaration of buffer_diff. I hope that answers the question. Basically it's due to a theoretical concern that when the FIFO is filled while the interrupt is emptying it, we get a spurious second interrupt that actually will not be able to transfer data.
Basically, because the hardware is broken. We need to be able to do a multi-block transfer where the blocks are not contiguous in RAM (the architecture of the FAT driver (BlockCache) requires this). The manual says that when DMA is used with SDIO, hardware handshaking between the DMA and SDIO should be enabled so that the DMA automatically knows when the data ends. This implies that the entire transfer of possibly multiple blocks is to a contiguous range of RAM, which is not what we need. I had tried to disable hardware handshaking and write the code such that when DMA transfers one block, I get an interrupt and the interrupt starts DMA for the next block (all while the SDIO is still active). But it did not work (don't remember exactly what happens, I think it failed to read the last few bytes?). Presumably the hardware was never tested in that configuration. Now, it is possible to disable multi-block transfers, then DMA can work. Before I implemented multi-block transfers, this driver did use DMA. Here is the commit where I implemented multi-block and changed the driver to not use DMA: 25ba98f If you want you can change the driver to do DMA; if you do this you will have to change the MaxIoBlocks (near the top) to 1 (the FAT driver will then know not to do multi-block transfers). |
Thank you for prompt answer. I will try to understand implementation of SDIO not only as sd-card module, but with your implementation FAT and main logic of aprinter. Also I will check your previous DMA implementation. After all I will open new merge request. br, |