discovery icon indicating copy to clipboard operation
discovery copied to clipboard

Led roulette blocks execution when using STM32F3348-DISCO

Open nvinuesa opened this issue 7 years ago • 4 comments

Hi Jorge, first of all thanks a lot for your great job on rust-embedded 😃 .

I am using the STM32F3348-DISCO board which is the replacement for the STM32F3DISCOVERY (no longer available in my country).

When I follow the instructions, everything builds, flashes and starts debugging correctly. The problem is that if I hit continue (in gdb) after setting the breakpoint, it blocks indefinitely; and if I step a few times, I arrive to this statement and it blocks:

   ┌──asm.s────────────────────────────────────────────────────────────────────────────────────────┐
   │1         .global HardFault                                                                    │
   │2         .thumb_func                                                                          │
   │3       HardFault:                                                                             │
   │4         mrs r0, MSP                                                                          │
  >│5         bl UserHardFault                                                                     │
   │6                                                                                              │
   │7                                                                                              │
   │8                                                                                              │
   │9                                                                                              │
   │10                                                                                             │
   │11                                                                                             │
   │12                                                                                             │
   │13                                                                                             │
   │14                                                                                             │
   │15                                                                                             │
   │16                                                                                             │
   │17                                                                                             │
   │18                                                                                             │
   │19                                                                                             │
   │20                                                                                             │
   │21                                                                                             │
   │22                                                                                             │
   │23                                                                                             │
   │24                                                                                             │
   │25                                                                                             │
   │26                                                                                             │
   │27                                                                                             │
   │28                                                                                             │
   └───────────────────────────────────────────────────────────────────────────────────────────────┘
remote Remote target In: HardFault                                              L5    PC: 0x80003ee
Loading section .rodata, size 0x6c lma 0x80004a0
Start address 0x800023a, load size 1286
Transfer rate: 4 KB/sec, 428 bytes/write.
(gdb) l
(gdb) l
(gdb) step
Reset ()
    at /Users/nico/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.5.2/src/lib.rs:494
(gdb) step
(gdb) step
HardFault () at asm.s:4
(gdb) step
(gdb) step
Note: automatically using hardware breakpoints for read-only addresses.

Now, I am aware that this problem may come from the fact that the board is not exactly the same as you used; and more specifically, when compiling I see Compiling stm32f30x v0.7.0 and my board uses the STM32F334C8 MCU instead of an STM32F30x.

Is there something I can change or would you have any idea how to solve this?

Thanks a lot

nvinuesa avatar Aug 25 '18 19:08 nvinuesa

The STM32F3DISCOVERY has a STM32F303VCT6 microcontroller while your board has a STM32F334C8. The 33x and 30x series are going to be similar in terms of peripherals, but not fully compatible. Differences such as a peripheral being at a different address, or simply because they have different amounts of RAM and/or Flash, can cause the HardFault exception to be raised, as you have seen.

You'll need to look at forking the japaric/f3 repo and patching it to support the STM32F3x4 line instead of the STM32F30x line, or skipping the F3 crate entirely and using a lower-level crate like https://github.com/adamgreig/stm32-rs/blob/master/stm32f3/src/lib.rs.

thejpster avatar Aug 26 '18 16:08 thejpster

Great, I'll do that!

Thanks

nvinuesa avatar Aug 27 '18 07:08 nvinuesa

hi all,

any update on this? (I have rhe same problem)

do you have a memory.x for this MCU?

thanks, Mark

MarkGrant06 avatar Sep 15 '18 17:09 MarkGrant06

OK.. I'll answer my own question... by updating the memory.x for the f3 crate to the one below, I can now get it to work:

MEMORY { CCRAM : ORIGIN = 0x10000000, LENGTH = 8K FLASH : ORIGIN = 0x08000000, LENGTH = 64K RAM : ORIGIN = 0x20000000, LENGTH = 16K }

_stack_start = 0x20001000;

MarkGrant06 avatar Sep 16 '18 06:09 MarkGrant06