Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: New to Arm cortex m3 - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

New to Arm cortex m3 Help getting started Rate Topic: -----

#1 User is offline   rsarm 

  • Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 09-June 09

Posted 09 June 2009 - 03:32 PM

Hi everyone,
I recently got an Arm cortex m3 microcontroller (stm32f103ret6). I'm interested in programming in assembly only. I received some software with the kit I bought (keil uvision, IAR workbench kickstart and ride7) but i find all of these a little confusing to use. Reading the book "the definitive guide to arm cortex m3", I beleive the simplest way to compile and build assembly code is using arm tools, I found some of these in the keil software directory (armasm, armlink, fromelf). the book describes assembling using this command line:

armasm --cpu cortex-m3 -o test.o test.s

this however doesn't work I realized i had to replace the "--cpu cortex-m3" with "--device stm32". This makes me wonder if there are different arm tools or variations in different software or if the book was just wrong? Or is this what your supposed to use on linux (I'm using windows)?

the next thing to do is to link the object I seen an example using the following command:

armlink --rw-base 0x20000000 --ro-base 0x0 --map -o test.elf test.o

my question is: is the ro (read only) supposed to be your code that goes into the flash? and rw is the data that goes to the ram?

My microcontroller's flash starts at 0x80000000 (i think), when linking should i set the ro-base at the address 0x80000000 or at 0x0, I've used flash loader demo to successfully upload sample code to my microcontroller.

I have also seen "startup code" on some programs, looking at the code it looks like it sets up the interrupt vector table and stack. is this absolutely necessary or can you get away with omitting this code and just setup the vectors you will be using? If someone can elaborate on this.

Any help would be greatly appreciated
0

#2 User is offline   bhav 

  • Regular Contributor
  • PipPipPip
  • Group: Members
  • Posts: 109
  • Joined: 05-October 06

Posted 09 June 2009 - 06:05 PM

View Postrsarm, on Jun 9 2009, 04:32 PM, said:

armasm --cpu cortex-m3 -o test.o test.s

this however doesn't work I realized i had to replace the "--cpu cortex-m3" with "--device stm32". This makes me wonder if there are different arm tools or variations in different software or if the book was just wrong? Or is this what your supposed to use on linux (I'm using windows)?


To answer this part... No it's the same tool. The --device option is a wrapper that will select the right CPU and any other options. I think it's likely that the book was written against either the RealView Compilation Tools, or an earlier version of the Keil tools.
1

#3 Guest_Joseph Yiu_*

  • Group: Guests

Posted 11 June 2009 - 08:35 PM

The assembly examples in the book are written using RealView Development Suite (RVDS). The command line options for KEIL ARM-MDK (Microcontroller Development Kit) are slightly different.
KEIL ARM ARM-MDK is target at microcontroller devices, while RVDS is targetted at supporting the general ARM architecture.

If you want to learn assembly programming with KEIL ARM-MDK, the easiest way to to use the uVision IDE to create a new project. The Cortex-M3 book has already got examples of creating C projects. Creating assembly project is similar, and this will create the correct compiler and linker settings for you.

Please notice that the errors in the book is listed on
http://www.arm.com/miscPDFs/21948.pdf

regards,
joseph
0

#4 User is offline   LarryP 

  • Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 16-June 09

Posted 16 June 2009 - 08:22 PM

View Postrsarm, on Jun 9 2009, 11:32 AM, said:

Hi everyone,
I recently got an Arm cortex m3 microcontroller (stm32f103ret6). I'm interested in programming in assembly only. I received some software with the kit I bought (keil uvision, IAR workbench kickstart and ride7) but i find all of these a little confusing to use.


Hello,

I'm only a tiny bit farther along, also using a board with an STM32f103 series chip.
I found the info on this: Fosstronics_Wiki
to be most helpful in setting up a toolchain, and using it.

In particular, this site has an article titled "Writing a minimal C program for the STM32 Primer"
that is
(a) really minimal (under 20 lines, not counting comments) and self contained,
(b) detailed, including snippets of console log,
© gives enough detail (e.g. on linker scripts and how to look at the raw bytes) to get one started doing more.

I was able to adapt this (from the STM32 primer) to a different board, and get it working via serial download.
If you're willing to dip a toe into the C language, this may be a good way to start. (And if not, it shows the assembly code that results, so you could work from that if you prefer.)

FYI, some more details, and a couple screen shots are online on my repRap build blog in the entry dated may 24, 2009.

Hope this helps,

Larry
0

#5 User is offline   th33lf 

  • Member
  • Pip
  • Group: Members
  • Posts: 39
  • Joined: 21-January 09

Posted 23 June 2009 - 07:03 AM

View Postrsarm, on Jun 9 2009, 09:02 PM, said:

I have also seen "startup code" on some programs, looking at the code it looks like it sets up the interrupt vector table and stack. is this absolutely necessary or can you get away with omitting this code and just setup the vectors you will be using? If someone can elaborate on this.


Hi,
First of all, one thing here is Cortex M3 has been designed to be programmed almost entirely in C. There is no asm wrappers or startup code required. So my best advice would be to try using C, coz thats what it has been designed for ! However, you could easily make it run you assembly language program, provided you give it the proper startup values. Unlike most other processors, M3 doesn't start executing from location 0. It expects the initial value of Stack Pointer at location 0x00000000, and the starting address of your program at location 0x00000004. If you place these properly, there shouldnt be any trouble running you r code..
0

#6 User is offline   LarryP 

  • Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 16-June 09

Posted 23 June 2009 - 11:12 AM

View Postth33lf, on Jun 23 2009, 03:03 AM, said:

Hi,
First of all, one thing here is Cortex M3 has been designed to be programmed almost entirely in C. There is no asm wrappers or startup code required. So my best advice would be to try using C, coz thats what it has been designed for ! However, you could easily make it run you assembly language program, provided you give it the proper startup values. Unlike most other processors, M3 doesn't start executing from location 0. It expects the initial value of Stack Pointer at location 0x00000000, and the starting address of your program at location 0x00000004. If you place these properly, there shouldnt be any trouble running you r code..



Greetings all,

You might get away with not setting up the vector table for a simple learning exercise, but longer term, it leaves you vulnerable to *ugly* bugs. Sooner or later, one of those interrupts will be enabled, so leaving the vector table unset is a bad habit. I suggest you (at minimum) point all of the other interrupt vectors at a (common) do-nothing interrupt service routine. There's example code out that does this, as mentioned previously in this thread. Compared to other architectures, the setup needed for running (compiled from) C code is simple, straightforward and free to use. Why not take advantage of it?

-- Larry
0

#7 User is offline   rsarm 

  • Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 09-June 09

Posted 23 June 2009 - 07:58 PM

Thanks for all the responses everyone,

I guess some of you are wondering why i asked to program in assembly, the reason is to familiarize myself with the arm microprocessor(and the new thumb instructions) and because I always thought that when using higher level language the coding is not very efficient. But i guess using C won't make too much of a difference (only make my life easier)...I didn't know it was designed to be programmed in C. I was actually following the book "the definitive guide to arm cortex m3". also I found most software a little confusing to use (keil and IAR workbench).

This post has been edited by rsarm: 23 June 2009 - 08:35 PM

0

#8 Guest_Joseph Yiu_*

  • Group: Guests

Posted 23 June 2009 - 08:46 PM

Chapter 20 of the book is "Getting Start with the KEIL RealView Microcontroller Development Kit". Maybe this chapter would help you. Also, this link might help too (errors found on the book : http://www.arm.com/miscPDFs/21948.pdf)
0

#9 User is offline   midiman 

  • Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 18-April 12

Posted 18 April 2012 - 10:39 PM

Just got your book on my Kindle Fire. Can't wait to march thru it cover to cover. I too, would like to program in assembly ... it's what I've used my entire 40 years of micro programming. I have several realtime systems under my belt, written in assembly, mostly 8 bitters. I've looked at C and have started an on-line course to learn it, but I don't spend much time with it. I've got the lite version of ARM-MDK installed.

Kenny

View PostJoseph Yiu, on 11 June 2009 - 08:35 PM, said:

The assembly examples in the book are written using RealView Development Suite (RVDS). The command line options for KEIL ARM-MDK (Microcontroller Development Kit) are slightly different.
KEIL ARM ARM-MDK is target at microcontroller devices, while RVDS is targetted at supporting the general ARM architecture.

If you want to learn assembly programming with KEIL ARM-MDK, the easiest way to to use the uVision IDE to create a new project. The Cortex-M3 book has already got examples of creating C projects. Creating assembly project is similar, and this will create the correct compiler and linker settings for you.

Please notice that the errors in the book is listed on
http://www.arm.com/miscPDFs/21948.pdf

regards,
joseph

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic