cancel
Showing results for 
Search instead for 
Did you mean: 

Programming STM32 only with CMSIS.

dnj
Associate III

Hi,

I would like to start using my discovery board STM32F0308 without HAL library.

Where should I start?

Now I use CubeMX to generate Makefile but I would like to write this on my own, linker script and startup too.

Shall I ask another question about programming only with using CMSIS?

I'm tired of reading this tones of lines without understanding, I prefer bare-metal programming with registers.

tl dr section;

I want to just use text editor and command line to program and debug STM32s.

1 ACCEPTED SOLUTION

Accepted Solutions

> I want to just use text editor and command line to program and debug STM32s.

You'll need also a PDF reader. And I strongly recommend Total Commander or equivalent.

I have some barebones progamming examples on efton.sk/STM32 . You probably have some gcc binary from the Cube bundles or the eclipsoids, or get one from ARM. For simple projects, I avoid using make as it's an added hassle which pays off only with moderately large to huge projects - I simply call gcc from a batch file.

Then you have to download your code to target. There's many ways to skin the cat - you can avoid the debugger "pods" like STLink or JLink and use the built-in bootloader in some form, but I'm not sure about the details. Or use e.g. STLink, it comes with the STLink Utilities (or its Cube form) both in windowy and command-line form.

You can then debug using oldfashioned (but in no way unusable) methods - LED blinking, wiggling a pin observed by oscilloscope or LA, using debug printouts (and I'd recommend you to avoid printf() and family for the barebones experience, alleviating you from the associated problems - write your own simple print routines) through some serial channel or any other means.

Or, if you want to use the on-chip debug interface, you probably go for gdb with some suitable server (usually openocd) attaching to the debugging "pod" (e.g. STLink). I'm not very versed in this - I can get this going for myself, but won't offer guidance.

Which one from these items you'd want to elaborate on further? (I'm not offering more help, but knowing your exact standpoint may help others who'd want to help you).

JW

PS. Oh, and what TDK said above... Absolutely yes, you should start with the simplest loopdelay blinky and evolve from that.

View solution in original post

14 REPLIES 14
TDK
Guru

Start with a simple task, and try to do that. Change clock settings. Blink an LED. Whatever. Get used to reading the reference manual and understanding what the various registers do.

Hard to answer "How do I X?" when X is undefined. Don't want to use HAL? Simple, just don't #include any HAL files. CubeMX is going to generate code with HAL/LL. That's what it does. You will need to generate your own code.

If you feel a post has answered your question, please click "Accept as Solution".

> I want to just use text editor and command line to program and debug STM32s.

You'll need also a PDF reader. And I strongly recommend Total Commander or equivalent.

I have some barebones progamming examples on efton.sk/STM32 . You probably have some gcc binary from the Cube bundles or the eclipsoids, or get one from ARM. For simple projects, I avoid using make as it's an added hassle which pays off only with moderately large to huge projects - I simply call gcc from a batch file.

Then you have to download your code to target. There's many ways to skin the cat - you can avoid the debugger "pods" like STLink or JLink and use the built-in bootloader in some form, but I'm not sure about the details. Or use e.g. STLink, it comes with the STLink Utilities (or its Cube form) both in windowy and command-line form.

You can then debug using oldfashioned (but in no way unusable) methods - LED blinking, wiggling a pin observed by oscilloscope or LA, using debug printouts (and I'd recommend you to avoid printf() and family for the barebones experience, alleviating you from the associated problems - write your own simple print routines) through some serial channel or any other means.

Or, if you want to use the on-chip debug interface, you probably go for gdb with some suitable server (usually openocd) attaching to the debugging "pod" (e.g. STLink). I'm not very versed in this - I can get this going for myself, but won't offer guidance.

Which one from these items you'd want to elaborate on further? (I'm not offering more help, but knowing your exact standpoint may help others who'd want to help you).

JW

PS. Oh, and what TDK said above... Absolutely yes, you should start with the simplest loopdelay blinky and evolve from that.

dnj
Associate III

Then to not to dive in deep water at first I make CubeMX project and just don't use HAL library. I only let MX do linker, startup etc. stuff.

Thanks

I think I introduced myself wrong. I'm embedded dev but I always use HAL or prepared by someone project in other IDE and then I'm frustrated I don't know how it works... but guys I'll take your advice and try to separate from "automagic" tools step by step.😉

As I see you generated linker and startup file with Attolic (I mean blinky at your site EFTON).

> As I see you generated linker and startup file with Attolic (I mean blinky at your site EFTON).

Generated? No, I've simply stolen them from the templates in SPL or Cube (depending on the age of that example).

JW

> For simple projects, I avoid using make as it's an added hassle which pays off only with moderately large to huge projects - I simply call gcc from a batch file

Ok then, how you know how to enquire above files (startup and linker script) in compilation.

I think I can take them from Makefile prepared from CubeMX, but I'm curious how you did it.

Could you show me your batch file for compilation? Maybe there are some usefull comments.

dnj
Associate III

Ouch i see those .bat files =)

Could you tell me what does it mean in c.bat file?

%2 %3 %4 %5 %6 %7 %8 %9