Skip to content
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

Please provide instructions for compilation #5

Open
Peemouse opened this issue Jul 24, 2019 · 11 comments
Open

Please provide instructions for compilation #5

Peemouse opened this issue Jul 24, 2019 · 11 comments

Comments

@Peemouse
Copy link

Hi,

Could you provide instructions for the compilation ?
What software do we need ? STM32CubeMX ?
Is it possible to compile through terminal with GCC ?

Thanks,

Clément

@BluePygmyOwl
Copy link

Hi,
Same question. Would like to change something, but don't have the full Keil version and don't want to buy it. Tried SystemWorkbench, STM32CubeMX, arm-none-eabi-gcc but this gave a non-working bin-file.
Help appreciated. Did you succeed Peeemouse?

Thomas

@Peemouse
Copy link
Author

Hi,
Unfortunately, I couldn't build it.
But I'm full of hope with PR #6 from @khswong

@khswong
Copy link

khswong commented Jan 22, 2020

Sorry, I've been working on it sporadically. There was a bug in the linker file I provided in PR #6 ; would like @DieBieEngineering to verify that the new change works.

My environment:

System Version: macOS 10.15.2 (19C57)
Kernel Version: Darwin 19.2.0

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]

$ make --version
GNU Make 3.81

$ openocd --version
Open On-Chip Debugger  v0.10.0-esp32-20190708 (2019-07-08-11:04)

@BluePygmyOwl
Copy link

Yes! @khswong big thank you! The linker file update did it. Forgot to look at the FLASH locations and wasn't triggered by SW4STM32 to change that.

Now I run in the second problem. The firmware is not matching the firmware packages in DieBieMS-Tool, see screenshot.
diebiems_firmware_version

How should I solve this? Download Qt and change DieBieMS Tool? Wouldn't know where to start even..... pls help.

What I did regarding the Firmware (from start to end, sorry for the story and yes, probably some things could be done differently, but this was my log):

  1. Copy pins layout from STM32F303Cxt.ioc to a new file (via notepad++), because only then I could give it my own project name.
  2. Have CubeMX (v1.11.0) generate the code. Open it in SW4STM32.
  3. Overwrite main.c (from efoildevelopment repository) by dragging from explorer to Eclipse window.
  4. Import the folders Libraries, Modules, HWDrivers, SWDrivers, Logo. Drag into window of Eclipse.
  5. No need to import CubeMX folder
  6. Import all arm_*.h files from efoildevelop in Drivers/CMSIS/Include to the project folder.
  7. Properties – C/C++ General – Path & symbols:
    a. Add includes to added folders as mentioned above to GNU linker
    b. Add sources directory for Libraries and Modules
  8. under C/C++ General  Path & Symbols  Symbols :
    a. Add symbol “ARM_MATH_CM4”
    b. Add symbol “__FPU_PRESENT” (although lateron SW4STM32 will warn you it is double defined...but it doesn’t catch it when I didn’t had this symbol defined strangely)
    c. Add symbol and value “GPIO_SPEED_HIGH” = “GPIO_SPEED_FREQ_HIGH”
    d. Add symbol and value “__ADC1_CLK_ENABLE()” = “__HAL_RCC_GPIOA_CLK_ENABLE()”
    e. Add symbol and value “__I2C1_CLK_ENABLE()” = “__HAL_RCC_I2C1_CLK_ENABLE()”
    f. Add symbol and value “__I2C2_CLK_ENABLE()” = “__HAL_RCC_I2C2_CLK_ENABLE()”
    g. Add symbol and value “CAN_RX0_IRQHandler” = “USB_LP_CAN_RX0_IRQHandler”
    h. Add symbol and value “__nop()” = “__NOP()”
  9. Get assembler to make a bin file too: go to C/C++ build –> Settings –> Build steps:
    a. In command line place:
    arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex" && arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.bin" && arm-none-eabi-size --format=berkeley "${BuildArtifactFileName}"
  10. Append “-u _scanf_float” to string in C/C++ Build  Settings  MCU GCC Linker – Linker flags field
  11. RAM and ROM sizing, change STM32F303CCTx_FLASH.ld as per KHSWONG
  12. Overwrite stm32f3xx_hal_can.h, stm32f3xx_hal_can.c, stm32f3xx_hal_iwdg.h, stm32f3xx_hal_iwdg.c, stm32f3xx_hal_it.h (From STM32F3xx_HAL_driver/Inc), stm32f3xx_hal_it.c with those files from DieBieMS
  13. Add “#include "main.h”” to main.c and modConfig.h
  14. Add to main.c under the includes: “
    /* Private variables ---------------------------------------------------------*/
    ADC_HandleTypeDef hadc1;
    CAN_HandleTypeDef hcan;
    I2C_HandleTypeDef hi2c1;
    I2C_HandleTypeDef hi2c2;
    IWDG_HandleTypeDef hiwdg;
    SPI_HandleTypeDef hspi1;
    SPI_HandleTypeDef hspi2;
    TIM_HandleTypeDef htim2;
    DMA_HandleTypeDef hdma_tim2_up;
    DMA_HandleTypeDef hdma_tim2_ch1;
    DMA_HandleTypeDef hdma_tim2_ch2_ch4;
    UART_HandleTypeDef huart2;
    DMA_HandleTypeDef hdma_usart2_rx;
  15. Add “#include "modConfig.h"” to driverSWLTC6803.h and driverSWLTC6803.h
  16. If main.h contains “#define LTC_CS_PIN”, change that to “LTC6803_CD_PIN”, etc. Add “#define LTC6804_CS_Pin GPIO_PIN_4 and #define LTC6804_CS_GPIO_Port GPIOA” (or do this via Symbols)
  17. (restart SW4STM32 to have it apply the changes)

What to do with the files? Start a branch? Or leave it to you khswong?

@khswong
Copy link

khswong commented Jan 22, 2020

What's the latest version of the firmware that the tool supports? If the version in Main/generalDefines.h is greater than the supported version it won't work. Don't recommend changing it though.

@DieBieEngineering
Copy link
Owner

A change in firmware version written in the firmware goed almost always hand in hand with a change in config packet format. Currently the latest firmware is not yet capable of controlling all hardware, I will combine and match everything ( such that there is a working combination ) asap. I am currently working on new hardware for two new batteries for a customer, as soon as that is out for production I'll adapt the firmware to support all hardware and merge it.

@BluePygmyOwl
Copy link

Great progress, thanks for doing that @DieBieEngineering ! Will you stick to Keil toolchain or provide both options (GCC)?

I am in favour of accepting to have to change the 'safe firmware list' in the DieBieMS-Tool, rather than using an old version number on with my own tweaked BMS firmware. See also my question at the DieBieMS-Tool project.

@Peemouse
Copy link
Author

What to do with the files? Start a branch? Or leave it to you khswong?

IMO, do a fork, update files a do a PR to this repo.
Maybe a new branch can be made if @DieBieEngineering wants to stick to Keil.

I'm really (I mean REALLY) interested into using your work to contribute as well to the FW of this great BMS.
Since DieBieMS Tool is based on VESC Tool, which I'm comfortable with, I may help you out with the code if you need. 👍

@BluePygmyOwl
Copy link

Made a fork of the original DieBieMS firmware to my repository here. Let me know if this helps you.

@Peemouse
Copy link
Author

Wonderful @BluePygmyOwl , thanks a lot !
Could you enable the issue system on your fork ?
I encounter some errors while trying to compile.

@BluePygmyOwl
Copy link

BluePygmyOwl commented Jan 26, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants