This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CortexM3

I have a very simple CortexM3 based virtual platform example as below

The amba_pv_m2 is connected to a memory in the top. The BusDecoder master port address range is 0x0-0x3FFFFFFF

I have the following C program

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Hello!!!\n");
    return 0;
}

and the following make commands

armcc --cpu=Cortex-M3 -g -O2 -c -o hello.o hello.c
armlink --cpu=Cortex-M3 --ro-base 0x00000000  -o hello.axf hello.o

With that when I load the axf into the core and execute, I see the Hello is printed.

Bow I want to load the SW at 0x40000000. For that I did the following chnages

- BusDecoder master port address range 0x40000000-0x7FFFFFFF and make command as

armcc --cpu=Cortex-M3 -g -O2 -c -o hello.o hello.c
armlink --cpu=Cortex-M3 --ro-base 0x40000000  -o hello.axf hello.o

with that the when I run the platform, it stucks somewhere and I am not getting the Hello output.

It seems I am missing some thing here.

Can you guys help me on this ?

Thanks

Khushi

Parents
  • Sorry but actually I am new to this.

    I see armlink has options --ro-base and -rw-base. How these are related with CortexM3 application if I can only load my sw on 0x000000. Also I see some folks taking about some startup and boot code etc. When these are needed ?

     I am looking for some simple example where in startup code I can map.

    Thanks for your help

Reply
  • Sorry but actually I am new to this.

    I see armlink has options --ro-base and -rw-base. How these are related with CortexM3 application if I can only load my sw on 0x000000. Also I see some folks taking about some startup and boot code etc. When these are needed ?

     I am looking for some simple example where in startup code I can map.

    Thanks for your help

Children
  • Ok, step by step.

    Armlink - linker which links compiled code (object files) into an executable file, then this executable file will be flashed (by flashloader or debugger) into the memory of microcontroller or microprocessor (memory can be onboard or external to chip).

    Read Only - for example flash memory of microcontroller which commonly starts at 0x0 memory address.

    Read Write - this can be SRAM memory (SRAM for code, SRAM for data), DRAM or other external memory (always look at the memory map of microcontroller or microprocessor  where the particular memory starts).

    Different chipmakers implement different boot sequences for their chips.

    First, when you power your chip it starts with special reset sequence to configure system (for example, configuring clocks for processor, system bus, flash memory), then it starts booting from reset address (it is in the vector table in the flash memory) and jumps to code section.

    Startup code configures your system for work (your chip has to be configured to be ready to carry out your tasks), you can write this code to configure different clock frequencies or processor modes, to enable and to configure different controllers implemented on the chip (peripherals).

    Only after reset and boot sequences your own code will be executed (for example, in your case the code from function main).

    To start, you have to understand that Cortex M3 is only a core of processor or heart of processor, major manager of microcontroller.

    Read appropriate literature about architecture of ARM Cortex M3 to understand how it works (ARM Cortex M3 Processor Technical Reference Manual, Cortex M3 Devices Generic User Guide,  also you can read ARMv7-M Architecture Reference Manual for deeper understanding).

    http://infocenter.arm.com/help/index.jsp

  • In addition to the excellent advice already given, you might want to consider getting a decent textbook to help you to properly understand the Cortex M3 architecture?

    Joseph Yiu's book "The Definitive Guide to Arm Cortex M3 and Cortex M4 Processors" is a popular choice is highly recommended by many.

    Another excellent book for beginners is Daniele Lacamera's book "Embedded Systems Architecture" (published by Packt in 2018) since this has chapters describing the boot process and memory layout for Arm-v8M MCUs. You can often get ebook versions of Packt books from their website  for as little as $10 (or even free) so it is worth taking a look to see if there is anything else that might help you get started.