5

I've been having trouble using keil MDK on ubuntu 18.04. After doing a couple of trial I am able to use uVision IDE of keil on my ubuntu os. Everything working fine but while trying to program my mcu it shows "No ST-Link Found". But as I insisted to be using linux I tried to install stm32cube Programmer hopping try to do somehting with hex file, but didn't work out. But somehow I managed st-link utility(which works on command line).

Now If I convert eclipse's elf file to bin or hex and load to my stm32f103vet though st-link utility, it works just nice! But when I flash hex file generated from keil, it shows nothing. Doesn't work. I am tired to try to program stm32 using keil MDK.

So if there is anybody who is using Keil MDK on his linux os please knock here. Please help me out!

Naasif
  • 495
  • 2
  • 6
  • 13

1 Answers1

7

This isn't exactly an answer to your question directly per se, but it may still get you where you need to go in the end, and it's more than a comment, so I'll post it as an answer:

ST Development cross-platform tools with native Linux support:

I develop on Linux. I highly recommend you just switch to native Linux tools and drop Keil. ST has a full suite of natively-supported Linux Tools, which is one of the reasons I love ST so much (they are truly supporting Linux in everything they do):

  1. STM32CubeIDE - https://www.st.com/en/development-tools/stm32cubeide.html

  2. STM32CubeProgrammer - https://www.st.com/en/development-tools/stm32cubeprog.html <-- I love this tool, as it has a command-line version that works nicely. Ex command to write, verify, and start:

    STM32_Programmer_CLI -c port=SWD -w path/to/myhex.hex -v -s
    
  3. STM32CubeMX (built into STM32CubeIDE, so you don't need this separately necessarily unless you are using Eclipse instead of STM32CubeIDE) - https://www.st.com/en/development-tools/stm32cubemx.html

  4. Update May 2020: see my Eclipse setup instructions too: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/eclipse/Eclipse%20setup%20instructions%20on%20a%20new%20Linux%20(or%20other%20OS)%20computer.pdf. STM32CubeIDE is Eclipse-based so a lot of my configuration instructions here in my PDF should work in that too, though I haven't yet tried since I'm working on other projects now.

Other tools you may be interested in:

  1. Segger J-Link debug and programming probes: https://www.segger.com/products/debug-probes/j-link/

    • Work nicely with their free Ozone software, which can debug FreeRTOS applications too: https://www.segger.com/products/development-tools/ozone-j-link-debugger/

    • Can also be used to upload code from the command-line. Heres how to upload code in a single command using the Segger J-Link:

      JLinkExe -device STM32F777VI -if SWD -speed 12000 -AutoConnect 1 \
      -CommandFile /path/to/mycommandfile.txt
      

      Where mycommandfile.txt contains simply 4 commands:

      # reset mcu; Note to self :): You MUST do this before attempting to call 
      # `loadfile` or else it will fail; this reset command is in place of 
      # power cycling which I otherwise used to have to do all the time when 
      # using the Segger programmer!
      r 
      # flash a hex file to your chip
      loadfile /path/to/myhex.hex
      # reset no halt (ie: reset the mcu and start running your application 
      # you just loaded to it)
      rnh 
      exit
      
  2. You can use Eclipse on Linux as your IDE - buy this ebook (Mastering STM32, by Carmine Noviello) to see full setup instructions - https://leanpub.com/mastering-stm32


Another note about running Windows tools in Ubuntu: Wine rarely works well for me except on the simplest of programs. Usually what I do is install Virtual Box (no cost) inside Ubuntu, install Windows 10 inside Virtual Box (no-cost download straight from Microsoft), then install whatever Windows software I need inside Windows 10.

That being said, I still recommend you ditch Keil and use native STM32 Linux tools, but the Virtual Box trick really comes in handy when there's some piece of software that otherwise truly cannot be run and has no good substitute. Linux Ubuntu is my primary OS on all my home computers now, so I've had to use my Windows 10 virtual machine inside Virtual Box on occasion.

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
  • Thank you for your suggestions. I really appreciate that. – Naasif Aug 01 '19 at 18:09
  • One more thing to say. Do you think STM32Cube IDE works well for all kind of Embedded Applications like RTOS, Embedded Linux and other things. I mean do you think they are as much as rich as like keil? – Naasif Aug 01 '19 at 18:14
  • 2
    They support RTOS really well via FreeRTOS. I can't speak to embedded Linux on mcus, and I've never used Keil, but I doubt they are as rich as Keil, as most paid products find their niche by adding some of this extra "richness" I think. Generally what I've found is that expensive paid products are limiting in some ways, but make some hard things easy, and are easier to get started. No cost tools generally provide more freedom but are harder to get started with, and require more study and community support perhaps. I don't know for sure on Keil though, like I said. – Gabriel Staples Aug 01 '19 at 18:15
  • 1
    Ah! I see. So this is it. THank you very very much for your help Mr. Gabriel Staples. May Allah bless you. – Naasif Aug 01 '19 at 18:35