Closed dzarda closed 2 years ago
No problem. Send the PR. It will be merged.
Thank you. It will require somehow handling the dependencies. E.g stm32.h
uses a long path in its includes as opposed to only having "stm32fxx.h" (PlatformIO wants that for ststm32
). I'll think about a clean way around this.
For now I have simply copy pasted the thing into my project.
This is a simply wrapper for the generic CMSIS includes provided by STM. I didn't find a solution like #include<avr/io.h>
for the AVR, so i made it.
There are some utility macro's in this include. I can move them to the library code.
Why is this full path needed? "STM32F1xx/Include/stm32f1xx.h"
I've never seen it used like this. From my experience -I
always points to Include/.
Anyway having it part of libusb OOTB would be slightly easier not only for PIO consumers but everyone.
Just followed CMSIS 5 guideline.
I use CMSIS 5 with the includes from the ST git repo. Hmm. Looks they's can be got as submodules now.
-I
location (sadly).-I
to the stm32f1xx.h
directlyWhy? Looks like there is a pretty good described structure:
<cmsis_root>
+ CMSIS
+ Device
+ <Vendor>
+<Device>
+ Include
+ Source
+ ARM
+ GCC
+ IAR
BTW, Which define/attribute/other_mark usually used in the PlatformIO to determine what kind of device-specific code must be used ?
The structure is specified well, but they don't tell you where to point the includePath.
PlatformIO expects this to work: #include "stm32f1xx.h"
The ST determination macros are available in ststm32
, that's all fine: #if defined(STM32F0)
For completeness - support would require selecting the appropriate port source based on the STMXXX macros. Back then I got sorta stuck on that, but should be doable.
Old issue, but allow me to chime in:
As far as I can tell, the defines set in PlatformIO for STM32 boards are a bit of a mystery, what I always end up doing in my projects is to define the STM32F1
macro etc myself, using build_flags = -DSTM32F1
in my platformio.ini
files.
As for stm32.h
, I think the following alternative version would work with PIO - from this:
#elif defined(STM32F1)
#include "STM32F1xx/Include/stm32f1xx.h"
... to:
#elif defined(STM32F1)
#include "stm32f1xx.h"
(for all chip families, of course)
When framework = cmsis
is set in platformio.ini
, then the include path will automatically be set by PIO, and point to the CMSIS headers which it manages itself in ~/.platformio/packages/framework-cmsis-STM32F1/
etc.
The only changes involved, as far as I can tell, are to: 1) add a library.json
file (see docs), 2) include a modified stm32.h
for PIO use, and 3) publish this library so PIO will find it. Then, all anyone has to do is to add lib_deps = libusb_stm32
to their own platformio.ini
file and this library will get auto-installed from this git
repository, built, and linked-in.
I'm new to libusb_stm32
, but I'll see if I can get a demo working for the Blue Pill.
Ok, I think this will do the trick:
demo-pio/
folder: demo-pio.ziplibrary.json
file in repo root with this content:{
"name": "libusb_stm32",
"description": "Lightweight USB Device Stack",
"version": "1.0.0",
"keywords": "stm32, usb",
"authors": {
"name": "Dmitry Filimonchuk",
"email": "dmitrystu@gmail.com"
},
"repository": {
"type": "git",
"url": "https://github.com/dmitrystu/libusb_stm32.git"
},
"frameworks": [ "cmsis", "stm32cube" ],
"platforms": [ "ststm32" ],
"headers": "usb.h",
"build": { "includeDir": "inc" }
}
That's basically it, but if you don't have PlatformIO, you also need to install that. The simplest is the command-line version, see this page. Then from the shell (I'm assuming MacOS or Linux, have no experience with Windows), type the following:
cd demo-pio
pio run -t upload
The upload step will only succeed if a Blue Pill with ST-Link is attached, evidently.
SystemInit()
is not redefined, as it's already in the CMSIS code, and sets up some basics (not the clock, just stack and FPU, IIRC) - my solution was to copy the cdc_*.c
into one cdc_main.c
and change the main init sequence slightlylibrary.json
has all the info needed to define libusb_stm32
as a library which PIO understands - it's not published or installed anywhere, but the demo-pio
project loads the library as if it was (see platformio.ini
)pio publish
command I mentioned earlier (which requires setting up an account)lib_deps = dmitrystu/libusb_stm32
to their own platformio.ini
project file - this will work once the library.json
file is present on GitHubThere are probably some details I missed, but I think this library would be very nice to have available in any PIO project.
Major kudos for the library.
Simply including the repo in the PlatformIO project manifest doesn't work out of the box because of different
inc
vsinclude
convention:We can create a library.json manifest in the repo to enable this. What do you think?