Thread Tools
This thread is privately moderated by Phoboss, who may elect to delete unwanted replies.
Apr 14, 2018, 05:55 AM
Team WarpSquad
Phoboss's Avatar
Mini-HowTo

Windows CmdLine Buidling and Flashing tool for Silverware


Recently I switched from linux to windows environment, and I really missed automated ways of building with just one click. Instead of going back I decided to try my luck with keil toolkit and see what I can do.

NOTE: This tool may require tweaking, and is recommended for users familiar with scripting languages.
While it works for me it might not work for you and require editing the scripts to work properly. It was tested on Windows10 x64.

Steps:
1. Clone silverware from whichever fork you prefer:
silverxxx -> https://github.com/silver13/BoldClash-BWHOOP-B-03
NotFastEnuf -> https://github.com/NotFastEnuf/E011-...-H8-Silverware
me -> https://github.com/phobos-/Silverware ( based on NotFastEnuf fork with betaflight rates )
...

2. Download keil mdk_lite:
https://www.keil.com/demo/eval/arm.htm

3. Install keil mdk.
4. Download make.bat from here:
https://github.com/phobos-/Silverwar...aster/make.bat
5. Put make in the main code directory (i.e. into 'E011-BWHOOP-H8-Silverware' folder), and edit it:
- KEILDIR should point to your keil_v5/ARM/ARMCC/bin directory.
- ARM_PRODUCT_PATH should point to your keil_v5/ARM/sw/mappings directory (make sure it contains mdk_lite.elmap).
6. Tweak config, pids and other stuff to your liking in notepad.
7. Double click make.bat.
8. Wait a few seconds until it displays something similar to:
Program Size: Code=13978 RO-data=310 RW-data=524 ZI-data=1804

That's it! Your firmware is built! You can now find a file called BWhoop.hex in your root folder next to make.bat.

Alternatively if you don't want to download keil-mdk you can download just the compiler from here:
https://developer.arm.com/products/s...oads/version-5
But you would also need the licence file mdk_lite.elmap, which is only distributed as part of keil mdk-lite.

I also created a script to do one click flashing You can do it the usual way by running st-link utility, but if you want to do it quicker and pain free just connect your quad via stlink and double-click on flash.bat. It also can flash firmware by passing a parameter with firmware hex, bin or elf file path.

1. Download flash.bat from here:
https://github.com/phobos-/Silverwar...ster/flash.bat
2. Download openocd 0.10.0 binaries for windows and unpack them somwehere:
http://gnutoolchains.com/arm-eabi/openocd/
3. Edit flash.bat:
- DIR should point to your openocd-0.10.0/bin directory
4. Put your BWhoop.hex to the same folder as flash.bat.
5. Connect your quad via stlink to usb and run flash.bat.

The output should look like:
Code:
...
wrote 11264 bytes from file bwhoop.hex in 0.653263s (16.839 KiB/s)
** Programming Finished **
** Verify Started **
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x200007a8
verified 10828 bytes in 0.070882s (149.181 KiB/s)
** Verified OK **
** Resetting Target **
adapter speed: 1000 kHz
shutdown command invoked
Let me know if this way works for you, and if not I'll gladly help you out.

Cheers!
Last edited by Phoboss; Apr 18, 2018 at 11:05 AM.
Sign up now
to remove ads between posts
Apr 14, 2018, 07:07 AM
Registered User
Amazing work! Things like this really push the project forward. You got skills man!!
Apr 14, 2018, 07:24 AM
Registered User
527FPV's Avatar
I've build something similar for macOS. I'm really intrigued by your use of armcc instead of gcc.
Did you have a similar setup on Linux? Let's talk
Apr 14, 2018, 04:14 PM
Team WarpSquad
Phoboss's Avatar
Quote:
Originally Posted by 527FPV
I've build something similar for macOS. I'm really intrigued by your use of armcc instead of gcc.
Did you have a similar setup on Linux? Let's talk
I checked your tool out, great work. Kudos

I had a gcc + openocd setup on linux.
GCC is really convinient and open source, but keil armcc allows for better optimization. Keil is a commercial product, so it is closed source and requires a licence to run without any restrictions. The freeware licence allows for up to 32 Kbytes of code which is enough for silverware.

I feel like I have to turn pids down or filtering up on a gcc compiled hex compared to armcc hex or I get oscillations... I measured looptimes and on gcc compiled hex with strong software filters the looptime tends to get unstable and ends up closer to 1200us.
Stripped down acro only firmware flies the same, so it all depends on what you want to achieve and what are your goals. I think for brushless builds with sbus rx, dshot and more advanced filtering we'd have to either optimize the code for gcc which is a pain or compile with armcc.

The true balls to the wall reason I switched is because I got a new pc with windows10 and decided to stick with it. It has a linux subsystem feature which makes me feel a little bit closer to home

Quote:
Originally Posted by NotFastEnuf
Amazing work! Things like this really push the project forward. You got skills man!!
Did not feel right not to give something back to the community after looking at the work you and others have done I just hope it's going to be useful...
Apr 15, 2018, 04:20 PM
Registered User
SirDomsen's Avatar
Awesome idea! To get rid of Keil might open Silverware for more people. One reads often about troubles on the installation...
I see 527FPV already joined the thread, I'm curious what you both together could do
Apr 19, 2018, 02:23 AM
Brisbane, Australia
When using the cmd_compiler.zip you posted previously, what would I set the toolchain variant to?
SET ARM_TOOL_VARIANT=mdk_lite is causing an error when trying to make the hex file.
Apr 19, 2018, 03:17 PM
Team WarpSquad
Phoboss's Avatar
Quote:
Originally Posted by Ian444
When using the cmd_compiler.zip you posted previously, what would I set the toolchain variant to?
SET ARM_TOOL_VARIANT=mdk_lite is causing an error when trying to make the hex file.
Make sure that you either
have mdk_lite.elmap inside Keil_v5/ARM/sw/mappings/ folder, tools.ini in Keil_v5/ folder and remove ARM_TOOL_VARIANT and ARM_PRODUCT_PATH from make.bat
or
set ARM_TOOL_VARIANT=mdk_lite
set ARM_PRODUCT_PATH=<path to the folder with mdk_lite.elmap>
tools.ini is redundant in this case.
Apr 21, 2018, 03:24 AM
Registered User
527FPV's Avatar
Quote:
Originally Posted by Phoboss
I feel like I have to turn pids down or filtering up on a gcc compiled hex compared to armcc hex or I get oscillations... I measured looptimes and on gcc compiled hex with strong software filters the looptime tends to get unstable and ends up closer to 1200us.
Stripped down acro only firmware flies the same, so it all depends on what you want to achieve and what are your goals. I think for brushless builds with sbus rx, dshot and more advanced filtering we'd have to either optimize the code for gcc which is a pain or compile with armcc.
So I decided to test armcc on a Windows virtual machine. First: Thank you for this toolchain! It makes working with Windows suck less

It definitely flies better when compiled with armcc, plus I can use NFEs Kalman filters.

Now I NEED to figure out how to make armcc work on macOS. ARM is not very corporative in that regard
Last edited by 527FPV; Apr 21, 2018 at 03:41 AM.
Apr 22, 2018, 02:44 AM
Brisbane, Australia
I'm not familiar with scripting languages, so I'm not doing well but still keen to get this working. I started again from scratch, following the instructions in the first post to the letter as best I could, but still no luck. Attached screenshot shows where all the folders are and how I tried to set KEIL DIR and ARM PRODUCT PATH. Any pointers appreciated, or if some search terms could be suggested so I can google further.
Apr 22, 2018, 03:42 AM
Team WarpSquad
Phoboss's Avatar
Quote:
Originally Posted by Ian444
I'm not familiar with scripting languages, so I'm not doing well but still keen to get this working. I started again from scratch, following the instructions in the first post to the letter as best I could, but still no luck. Attached screenshot shows where all the folders are and how I tried to set KEIL DIR and ARM PRODUCT PATH. Any pointers appreciated, or if some search terms could be suggested so I can google further.
A dot in front of a path means it's a relative path. Relative to your make.bat, so it will look for a folder named keil_v5 in BoldClash-BWHOOP-B-03-master as configured currently.

I noticed you have your Keil_v5 directly on C drive. You can point to it by using an absolute path:

set KEILDIR=C:\Keil_v5\arm\armcc\bin
...
set ARM_PRODUCT_PATH=C:\Keil_v5\arm\sw\mappings
Apr 22, 2018, 03:51 AM
Brisbane, Australia
OK, thanks, that works. I did not expect to see the command window with a blinking horizontal cursor, I was expecting to see lines of text as the files processed/compiled. I think I had it working several times previous when I tried a few days ago, but when I saw nothing happening, I closed the command window. Next I'll try to flash, but I'll leave that for tomorrow. Also thanks for the explanation of relative and absolute paths, I had no idea, that makes a lot of sense, I couldn't find what I wanted with google.
Apr 25, 2018, 01:50 AM
Brisbane, Australia
I've had a few goes over the last few days at trying to get flash.bat to flash a board, but no luck. It appears I get about 5 or 6 lines of text in the command window before it instantly closes. I've tried a lot of different things, changed the "set DIR=.\openocd-0.10.0\bin-x64" to "set DIR=.\openocd\bin" and made sure the folders have the same name. The openocd folder, the bwhoop.hex and flash.bat are all in the same sub-directory. Are there any methods that can be used for troubleshooting?

The make.bat has been working like a champion, and flashes fine with ST-Link utility, so that's a good start!

Edit - attached screenshot of current folder structure. (I have not changed any folder structures within openocd.)
Last edited by Ian444; Apr 25, 2018 at 02:52 AM.
Apr 25, 2018, 02:34 AM
Registered User
527FPV's Avatar
@Ian444

Open cmd.exe and run the flash.bat from there. It will stay open and you can see what the error message says.

Apr 25, 2018, 03:16 AM
Brisbane, Australia
Thanks 527, I put the whole project in C drive (to make it easier for me for now), got this error message in the screenshot - "Can't find mem_helper.tcl" but that file is in there in the scripts folder. I'm not sure how to point it to the right place.

I had to pull the folders "target" and "interface" out of the original openocd folder (root directory?) and put them in the B03 folder with everything else, otherwise flashbat could not find interface/st-link-v2.cfg or target/stm32f0x. It is getting a bit messy, I need to learn how to set up the bat file but tutorials seem hard to find. I'll have more time in a couple of days though.

Edit - I'm not sure exactly how the openocd files from the link in the first post should be "unpacked". I unzipped it but unsure. I think the batch file is simply not getting what it needs, as in folders are in unexpected places. I downloaded another openocd from sourceforge but I think that one needs compiling, but it does have the correct folder name "openocd-0.10.0". No joy with that one. Getting closer though.
Last edited by Ian444; Apr 25, 2018 at 06:36 AM.
Apr 25, 2018, 07:47 AM
Brisbane, Australia
Success at last It flashes quickly. Bed time now...

Another way to keep the command window open is put "pause" as the last entry. Removing the "off" after echo (at the top) also helps see the progress. Sorry for all the newb questions to date, I think I'm OK now. It does say in the first post -
"NOTE: This tool may require tweaking, and is recommended for users familiar with scripting languages."
And most of all - thanks for the help, without it I would be lost.

Update - no "keil bug" with this method
Last edited by Ian444; Apr 26, 2018 at 03:15 AM.


Quick Reply
Message:
Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Mini-HowTo Some notes for silverware E011 flash on linux tetramonium Micro Multirotor Drones 2 Dec 23, 2018 04:29 AM
Download Compiling and flashing Silverware on macOS 527FPV Micro Multirotor Drones 2 Apr 13, 2018 04:02 PM
Discussion Micro MinimOSD, Windows 8.1, can't flash mwosd omster FPV Talk 25 Jan 19, 2016 09:35 AM
Discussion Having trouble connecting UNO to Atmel flashing tool / Flashing BLHeli Mooch37 Multirotor Drone Electronics 5 Sep 24, 2015 10:09 PM