bouffalolab / bouffalo_sdk

BouffaloSDK is the IOT and MCU software development kit provided by the Bouffalo Lab Team, supports all the series of Bouffalo chips. Also it is the combination of bl_mcu_sdk and bl_iot_sdk
Apache License 2.0
372 stars 128 forks source link

IDE setup #197

Closed nimish closed 9 months ago

nimish commented 9 months ago

The cmake/makefile mix of the repo makes it confusing to set up in an IDE. Is there a guide?

Alternatively I stripped out the custom CMake code here: https://github.com/nimish/bl616-tmpl but it's not as complete

Jatsekku commented 9 months ago

Yeah, I agree, @sakumisue could you provide example how to use SDK as external dependency and how to compile out-of-tree application code on top of SDK?

sakumisu commented 9 months ago

@Jatsekku Just copy helloworld out of sdk and modify BL_SDK_BASE will work.

sakumisu commented 9 months ago

The cmake/makefile mix of the repo makes it confusing to set up in an IDE. Is there a guide?

Alternatively I stripped out the custom CMake code here: https://github.com/nimish/bl616-tmpl but it's not as complete

Sorry sir, i need to say your project has many problems.

target_link_libraries(lhal PUBLIC
    soc
    phyrf
    cherryusb)
sakumisu commented 9 months ago

Makefile is just used to run cmake cmd and modifiy some variables.

sakumisu commented 9 months ago

Like this, if you can write cmake project, i think you can know these comand, so where is mix?

build:Makefile
    $(CMAKE) -S . -B build -G $(cmake_generator) $(cmake_definition)
    $(MAKE) -C build -j8
    $(MAKE) -C build combine
nimish commented 9 months ago

The cmake/makefile mix of the repo makes it confusing to set up in an IDE. Is there a guide? Alternatively I stripped out the custom CMake code here: https://github.com/nimish/bl616-tmpl but it's not as complete

Sorry sir, i need to say your project has many problems.

  • When cmake builds done, your variables can not be modified, like COMX,
  • When we use other chips, we need to modify cmake file, no, we don't allow that
  • We don't allow these codes, we should add automatically
target_link_libraries(lhal PUBLIC
    soc
    phyrf
    cherryusb)
  • If we use cmake to build, it will be too much config to set, we don't allow that
    • and many other problems i do not want to say, so i suggest you remove your project and do not have such idea.

In general, I would like to know if there is a way to get a template project set up in CLion or VSCode using the existing makefiles and CMake.

The bl616-tmpl was my personal reorganization for the hw I use that integrates with the IDE and is simply an example. It supports incremental and parallel building along with IDE cmake integration so it is faster to iterate. The price of that is the explicit dependency handling. It is not something that the SDK itself should adopt without significant extra development.

gamelaster commented 9 months ago

I am using Bouffalo SDK with my project through CLion, and it works perfectly. This is how I have it configured: (NOTE: There are no Bouffalo SDK changes) CMake Options: -G "Unix Makefiles" -DCROSS_COMPILE=/home/gamiee/Desktop/tools/toolchain_gcc_t-head_linux/bin/riscv64-unknown-elf- -DCHIP=bl616 -DCPU_ID= -DBOARD=bl616dk -DBOARD_DIR= -DCONFIG_DEBUG=y -DCONFIG_ROMAPI=y -DCONFIG_USB_HS=y -DCONFIG_COMX=COM5 -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF -DCONFIG_TLSF=y Environment: BL_SDK_BASE=/home/gamiee/Desktop/tools/bouffalo_sdk

My CMakeLists.txt: image

As @sakumisu mentioned, there is no need for using Make files, everything can be easily used through CMake, with CLion or VS Code CMake integration.

I was even able to make auto-upload by Run command with terminal. If there will be interest, I can create sample CMake project with CLion configuration stored here.

sakumisu commented 9 months ago

I am using Bouffalo SDK with my project through CLion, and it works perfectly. This is how I have it configured: (NOTE: There are no Bouffalo SDK changes) CMake Options: -G "Unix Makefiles" -DCROSS_COMPILE=/home/gamiee/Desktop/tools/toolchain_gcc_t-head_linux/bin/riscv64-unknown-elf- -DCHIP=bl616 -DCPU_ID= -DBOARD=bl616dk -DBOARD_DIR= -DCONFIG_DEBUG=y -DCONFIG_ROMAPI=y -DCONFIG_USB_HS=y -DCONFIG_COMX=COM5 -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF -DCONFIG_TLSF=y Environment: BL_SDK_BASE=/home/gamiee/Desktop/tools/bouffalo_sdk

My CMakeLists.txt: image

As @sakumisu mentioned, there is no need for using Make files, everything can be easily used through CMake, with CLion or VS Code CMake integration.

I was even able to make auto-upload by Run command with terminal. If there will be interest, I can create sample CMake project with CLion configuration stored here.

Right, copy cmake comand from makefile into clion, so makefile is unuseful, just make command length lesss for user.

sakumisu commented 9 months ago

https://github.com/bouffalolab/bouffalo_sdk/blob/be623ceb7f18c70f3aafba2a0eceba5efc6a683a/project.build#L78

nimish commented 9 months ago

Great, thanks. I think this covers what I wanted. Perhaps this could be added to the README as well?