rust-embedded / discovery

Discover the world of microcontrollers through Rust!
https://docs.rust-embedded.org/discovery/
Apache License 2.0
1.46k stars 503 forks source link

Led roulette blocks execution when using STM32F3348-DISCO #109

Open nvinuesa opened 6 years ago

nvinuesa commented 6 years ago

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

thejpster commented 6 years ago

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.

nvinuesa commented 6 years ago

Great, I'll do that!

Thanks

MarkGrant06 commented 5 years ago

hi all,

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

do you have a memory.x for this MCU?

thanks, Mark

MarkGrant06 commented 5 years ago

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;