isabellesimova / HoverboardFirmware

50 stars 24 forks source link

Add PlatformIO capability - for easy building by newbies :). #6

Open btsimonh opened 6 years ago

btsimonh commented 6 years ago

this adds a folder containing a platform.io configuration file, and a readme.md which briefly describes how to use it.

This makes it easy to build on many platforms.

isabellesimova commented 6 years ago

Hi! I'm about to test this to double check it works -- in the meantime, I did some cleanup of my documentation. Would you mind adding something mentioning platformio to the README in the root directory and also move the platformio directory that you made to the new directory dev_env?

isabellesimova commented 6 years ago

Hi, I'm having trouble building it following your instructions. When I try to build it, I get:

src/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:54:10: fatal error: stm32f1xx_hal.h: No such file or directory

Any ideas on how to resolve this? If so, updating the README would be nice :)

btsimonh commented 6 years ago

interesting. In the platform.io file, there are entries for include folders this one: -I"${PROJECTSRC_DIR}\Drivers\STM32F1xx_HAL_Driver\Inc" should cause that file's folder to be in the include path.

my folders look like: image

where 'platformio' is the folder I created, then you whole repo goes in platformio/src/, and the platformio.ini straight in platformio/ The highlighted folder is where that header is. Pls compare and let me know if yours was the same and is still not working, or what error you made so we can adjust and readme to avoid it.

isabellesimova commented 6 years ago

Hi! Yeah, I was also confused about that... Anyway, I got the chance to take a deeper dive and got it to run successfully and simplified the process in doing so (downside is it includes all the src files, which doesn't take up much space so I'm going to let it slide for now). I updated the README and the config file and tried to push to your branch but I didn't have the permissions :( If you give me permissions, I'll push it and you can take a look and try the new .ini file out.

btsimonh commented 6 years ago

It would be great to get the platformio.ini to reside inside the repo, and be usable directly; but it alluded me. I have added you as a collaborator....

isabellesimova commented 6 years ago

Yeah, I got that working :) but could probably use a few tweaks to remove the extra src files. Anyway could you double check you added me as a contributor? I'm still getting permission issues and your repo is not showing up in my repositories list.

btsimonh commented 6 years ago

did you get an invite?

isabellesimova commented 6 years ago

Actually yeah, sorry forgot to accept the invite!! Just pushed - let me know what you think. I also need to run it to make sure the build actually works.

btsimonh commented 6 years ago

yep, confirmed working; however, you missed one trick with platformio. "## IDE

  1. Follow the ide installation guide. (It works with vscode or atom)
  2. Open the Hoverbot directory in your IDE
  3. Build it by typing in terminal:
    
    pio run
    ```"

-> "Once opened, there should be a tick button in the bottom of vscode which will build it (if using vscode; atom is very similar)), if not, try reloading vscode, or 'Debug/Open Configurations' worked for me. If your STLINK is attached to the same machine, pressing the 'right arrow' icon will build and upload..."

btsimonh commented 6 years ago

hmmm... strange do you see: Compiling .pioenvs\genericSTM32F103RC\FrameworkHALDriver\Src\stm32f1xx_ll_i2c.o

or does it build the HAL driver you gave it?

btsimonh commented 6 years ago

ahh... i see; you've added 'framework = stm32cube' which brings in the extras. So, will need to be careful that these don't change compared to your 'included' drivers, else one or the other won't build. Did you try a makefile build after the GPIO_SPEED_FREQ_HIGH and __HAL_IWDG_START mods? the NiklasFauth firmware builds fine with the platformio supplied hal libs. p.s. to force platformio to build everything again from scratch, use the 'clean' icon (the bin). Anyway, I'm VERY happy with the result :). thankyou.

btsimonh commented 6 years ago

(in the mean time, I've revised my pull request against the original repo for your platformio file :) - so more people should thank you).

isabellesimova commented 6 years ago

Hi! Glad to hear it works for you - I know it built for you but did you manage to upload it successfully and run? I can build and program with the makefile and it works fine, but when I try to use platformio my UART isn't working.

As for the platform, I would like to prune it down just to have the relevant files. It should be easy once https://github.com/platformio/platformio-core/issues/1367 is implemented. If I get the chance I'll dig into it a little more, otherwise it'll just sit on the backburner for now.

btsimonh commented 6 years ago

haha :). no, just doing some mods now, so will be uploading in the next hour or so (backporting all my goodness mods into the other repo; so will test the Other repo's platformio, but not this one.)..
But, have noticed one thing. With the new config, vscode does not seem to know about the defines in config.h (highlighting is not there for #ifdefed code).

isabellesimova commented 6 years ago

Okay! Chased it down to HAL_NVIC_EnableIRQ, so I'll see if I can get a fix for it.

Actually, I did a huge refactor that I'm gonna be pushing soon - it's moving some lines of code around, not declaring some of the private methods in the header file, just applying good practices to the code. If you're not too far in, it might be better to wait a few minutes for me to push before you have to backport more?

btsimonh commented 6 years ago

confirmed firmware still runs (screwed up my backport, but that can be fixed). p.s. I'm on a GD32 based board, not true STM32.

isabellesimova commented 6 years ago

Okay! Refactor is pushed and should be working :)

btsimonh commented 6 years ago

"vscode does not seem to know about the defines in config.h" - hover over the red underlined include at the top of the .c file, a lightbulb appears, or is just there, click on the lightbulb, it offers to add the path to vscode for you!.

update - not quite all. in the end, I set it explicitly in the vscode c_cpp_properties.json file as "inc"... :(

btsimonh commented 6 years ago

ohhh... and maybe no %f in sprintf any more....

isabellesimova commented 6 years ago

@btsimonh I updated the platform.ini file and added a script to do all the linking (mostly copied from their script that installs the stm32cube framework). Could you double check that it works for you? If it does, I think it's good enough to merge into the repo!