You are here

Getting Started / Prototyping Help

5 posts / 0 new
Last post
harrym
Offline
Last seen: 4 years 3 weeks ago
Joined: 2020-04-01 15:44
Posts: 2
Getting Started / Prototyping Help

Hi Guys - Ive been reading a fair bit on this site and looking at some of the projects that are ongoing. Looks like a great open source project with a big following!

I have an interest in developing hardware predominantly and would like to get a prototyping setup in place to have a go with the software and PC based tool to see what is possible before going all out on a design.

It looks like the STM32F407G-DISC1 eval board could be a good start, my thoughts were to prototype up a basic power stage and some sensors that I can connect to the eval board to see how it all interacts and try out the software and look at how parameterisation would work for custom hardware before getting into a more specific design.

I need to look at the schematic and the pins that are already utilised vs the VESC designs to see if everything that is required is already available as a starting point but wanted to check if this route has been followed before and if there are any hidden gotchas that I should know about sooner rather than later.

Cheers

Harry

harrym
Offline
Last seen: 4 years 3 weeks ago
Joined: 2020-04-01 15:44
Posts: 2

I now have a discovery board (STM32F407G-DISC1) and also have a DRV8301 evaluation board on the way (BOOSTXL-DRV8301) so I started looking at the pin out of the discovery versus the pin out of the VESC v4.12 hardware to see what pins needed by the VESC are already committed on the discovery board and if there is a work around on the discovery board.

In short there are a number of clashes in the pinout.

Some that look to be show stoppers:

  1. PC0 - TEMP_MOTOR- Can desolder a resistor to free this up on the discovery board (controls the power of the USB OTG which I dont think I will need)
  2. PA0 - SENS3 - Can desolder a zero Ohm link to free this up on the discovery board (lose a button input which I wont need)
  3. PA9 - H2 - Bit more tricky, this is connected to the USB Vbus signal, ideally this needs to be removed but will mean cutting a track and then I may have an issue powering the board when trying to connect to the VESC tool
  4. PA10 - H1 - Connected to the USB OTG ID line, can desolder a resistor to free this up - dont think I will need to retain this line so should be ok
  5. PC10 - EN_GATE - Connected to an external DAC not sure if it will matter remaining connected to that and running it to another device (the DRV-8301), will need to desolder the DAC or cut a track to free this up
  6. PC12 - FAULT - Same as above, need to cut a track or desolder the DAC to free up

Some that may be ok left alone for now whilst I am just prototyping:

  1. PA4 - TX_SDA_NSS - Dont think I need external UART at this time (think this is what this pin would be used for on the VESC?)
  2. PA5 - SCK_ADC_EXT - Dont think I need external UART at this time (think this is what this pin would be used for on the VESC?) 
  3. PA6 - MISO_ADC_EXT2 - I dont need external demand via an ADC at this time 
  4. PA7 - RX_SCL_MOSI - Dont think I need external UART at this time (think this is what this pin would be used for on the VESC? why are there three of these?)  
  5. PB10 - RX_SCL_MOSI - Dont think I need external UART at this time (think this is what this pin would be used for on the VESC? why are there three of these?) 
  6. PC7 - RX_SCL_MOSI - Dont think I need external UART at this time (think this is what this pin would be used for on the VESC? why are there three of these?) 
  7. PB6 - HALL_1 - Dont need hall sensors at this time
  8. PB9 CAN_TX - Dont need CAN at this time

Hoping that someone can help me out a bit as it looks like I have two options here:

  1. Run the standard firmware for v4.12 VESC meaning I will need to make some hardware mods (some that will be irreversible)
    1. Is there a precompiled source for the bootloader and firmware that I can flash via the onboard stlink hardware on the discovery board?
  2. Build firmware with a modified pin allocation for this board (there are loads of pins free as its the LQFP100 package) - This means I need to get the build environment up and running (probably need to get linux running on a machine to make this simpler as most info is based on linux from what I can see) and figure out how to re-allocate the pins to suit my application which will likely be a good thing to do for the long run but slow me down right now.

If anyone on here has done this before and can share any tips or highlight any pitfalls I may run into I would really appreciate the input.

Also if this is in the wrong part of the forum let me know so I can move it to the right place.

Cheers,

Harry

javmarina
Offline
Last seen: 3 years 9 months ago
Joined: 2019-10-30 00:13
Posts: 5

Hi Harry. As you said, there are a few showstoppers, so I can anticipate you that the approach of using the 4.12 hardware configuration is not valid (I would not make some of that irreversible modifications to the board). Regarding your question about the precompiled firmware and bootloader, they're available. The bootloader is not hardware-dependent and you can already flash it to the board using the STM32 ST-Link Utility program (I guess you're using Windows, right?). You can download the utility here and the compiled bootloader here. The utility is very straightforward, but tell me if you have issues using it. There are three bootloaders available, I would use "generic.bin" (more on that later).

As you guessed, you must use a custom pin allocation for the board. This doesn't only solve the issues about unavailable pins on the Discovery, but also gives you freedom to allocate the pins according to your needs. For example, I don't like having one pin for UART, I2C and SPI, so instead you can use separate pins. You should allocate all digital pins, even the ones you're not going to use (like Hall or CAN). Just leave them unconnected and disable the corresponding modules in the header files (see CAN_ENABLE as an example). In the case of analog pins, https://vesc-project.com/node/1510 is a good starting point.

My tip is that you first select analog pins and then allocate digital pins. That's because there are far more digital pins, specially in the Discovery board, which is LQFP100 (note that most VESC versions use LQFP64 package, so you might want to use only the pins available on LQFP64 if you want to make your own PCB in the future).

There are three essential documents: the datasheet (see Table 7 and 9), the reference manual (information about registers and under-the-hood details that you might find interesting) and the Discovery user manual. Seems like you already checked that last document. I find Table 6 and Section 7 extremely useful, you are going to use them A LOT.

To sum up, you have to create your own custom configuration. That means creating two files (source and header) in the hwconf folder. I recommend checking all the configurations already available and copy the parts that you need, or modify them (they can be your template). I made a hardware configuration that is "Discovery-ready", I might be able to send it to you.

When your hardware configuration is ready, modify conf_general.h, comment the selected configuration and add your own.

Finally, you have to compile the firmware. Fortunately, there is an easy way to do it on Windows without virtual machines or dual-boot. You can use Windows Subsystem for Linux (WSL), a lightweight shell interface that can run Linux commands. It's like executing Linux without a virtual machine. There are some limitations, but they don't affect this scope. You will need to install some packages: 'make' and 'gcc-arm-none-eabi'. Then, open a WSL command line on the root folder of the project, run 'make' and wait for the firmware to compile. Then, a new folder called 'build' will appear, containing the .bin file you have to flash onto the board (use STM32 ST-Link Utility the first time, then you can use the VESC Tool software, which is faster and less error prone).

I think you already have a lot of information to get started. Tell me about any issues that you have and I'll try to help you.

hexakopter
Offline
Last seen: 1 year 1 month ago
VESC Original
Joined: 2017-05-24 12:13
Posts: 94

Hi @javmarina, great response to harrym's questions. It sounds like you got something up and running with a STM32F407 Discovery board, right?

I have this conversation (https://vesc-project.com/node/323) on the forum in mind, where the the consensus is that the VESC code is limited to the STM32F405 when not wanting to rewrite a lot of the code. It looks like the STM32F405 and STM32F407 are very similar (even sharing the same datasheet) with some things like ethernet added to the F407. It would be good to know if one could use a STM32 Discovery board with just the changed hwconf files and all other Chibios related staff etc. untouched. Would be great when you can confirm that it is working for you fine like that on the STM32F407.

javmarina
Offline
Last seen: 3 years 9 months ago
Joined: 2019-10-30 00:13
Posts: 5

Right, as I said in that thread, both F405 and F407 work (they're fairly similar). In fact, all F4xx should work, but have not tested it. Good luck!