Giter VIP home page Giter VIP logo

funtechcortexmx_test's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

funtechcortexmx_test's Issues

Who caused the error?

Improve the handling of errors so we can find out what caused the error.

Niklas Johansson gave us this hint:

From
http://www.keil.com/forum/14555/

The Cortex-M pushes 8 registers on the stack on Hard Fault exception. Here is a code to read the memory address that caused it:

MRS     R0,PSP                  ; Read PSP
LDR     R1,[R0,#24]             ; Read Saved PC from Stack

See also:

[test03] link problem: sprintf do not work

test03 sprintf

There is a problem using sprintf.

Basic use of sprintf like

sprintf(str, "1234") 

turns into memcpy and works.

But when using some more advanced with %d it fails during linking

sprintf(str, "%d", 4321);

We get this link error:

..linking
arm-none-eabi-gcc  -Tsrc/stm32.ld -nostartfiles -mcpu=cortex-m3 -mthumb  -mfix-cortex-m3-ldrd -o main.elf main.o startup_stm32f10x.o test03.o
/usr/local/stm32/lib/gcc/arm-none-eabi/4.4.5/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'

More data

From

  • arm-none-eabi-objdump -S test03.o
    sprintf(str, "1234");
  be:   68bb        ldr r3, [r7, #8]
  c0:   4618        mov r0, r3
  c2:   f240 0100   movw    r1, #0
  c6:   f2c0 0100   movt    r1, #0
  ca:   f04f 0205   mov.w   r2, #5
  ce:   f7ff fffe   bl  0 <memcpy>
    sprintf(str, "%d", 4321);
  fa:   68bb        ldr r3, [r7, #8]
  fc:   4618        mov r0, r3
  fe:   f240 0100   movw    r1, #0
 102:   f2c0 0100   movt    r1, #0
 106:   f241 02e1   movw    r2, #4321   ; 0x10e1
 10a:   f7ff fffe   bl  0 <sprintf>

Link with ld and not gcc.

Thanks to Soeren Apel:

On http://fun-tech.se/stm32/OlimexBlinky/ld_float.php you mention a workaround for ld's inability to link the float library functions. It appears that this is caused by the need for multi-pass symbol resolving. The workaround you mention does work but it's unfortunately something I'd consider a hack. A cleaner approach to solving the issue is to make ld repeatedly resolve the symbols of the object files and the required gcc library:

$(LD) $(LFLAGS) -o main.elf --start-group -lgcc main.o startup_stm32f10x.o --end-group

More or less change

LD      = arm-none-eabi-gcc
$(LD) $(LFLAGS) -o main.elf main.o startup_stm32f10x.o

into

LD      = arm-none-eabi-ld
$(LD) $(LFLAGS) -o main.elf --start-group -lgcc main.o startup_stm32f10x.o --end-group 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.