Forum: Mikrocontroller und Digitale Elektronik STM32H743 mit U-Boot landet im HardFault


von Daniel S. (sany)


Lesenswert?

Hey,

Ich hoffe der Beitrag ist hier richtig, ich habe ein Custom-Board mit 
STM32H743IIT6, externem SDRAM (256 Mbit), QSPI und SDCARD. (In einem 
Testprojekt lief alles SDRAM, QSPI, SDCARD tadellos)

Ich möchte für den MCU in einer minimalsten Konfiguration u-boot 
kompilieren. Ich habe mir dafür die bereits vorhandenen STM32H743-EVAL / 
DISCO, Files kopiert und in eigene umgewandelt. Kompilieren klappte auch 
ohne Warnungen/Fehler.

Mit fummeln, habe ich auf dem USART2 eine Ausgabe, da die Vorlagen 
andere Pins zur USART2 nutzen und ich an meinem Board ein 
Quarzoscillator mit 25 MHZ habe.

Der Bootloader soll erstmal kein SPL haben, und die Firmware später von 
der SDCARD / eMMC laden.

Nun erhalte ich aber beim Booten immer einen Hardfault und scheinbar 
(lt. Register R0: 23f36fc0) schreibt U-boot in die falsche RAM adresse.

(Die CFG_EXTRA_ENV_SETTINGS, erstmal ignorieren, die sind erst für den 
eigentlichen Bootprozess wichtig)
1
U-Boot 2025.07-rc1-00075-g0c8a89d252c3-dirty (May 04 2025 - 12:02:51 +0200)
2
3
Model: STMicroelectronics STM32H743i-EVAL board
4
DRAM:  Hard fault
5
pc : 08000a86    lr : 0800bf37    xPSR : 01001800
6
r12 : 23f36ff8   r3 : 00000000    r2 : fffffffc
7
r1 : 00000000    r0 : 23f36fc0
8
Resetting CPU ...
stm32h743-custom_defconfig:
1
CONFIG_ARM=y
2
CONFIG_ARCH_STM32=y
3
CONFIG_SYS_MALLOC_LEN=0x00100000
4
CONFIG_NR_DRAM_BANKS=1
5
CONFIG_ENV_SIZE=0x2000
6
CONFIG_DEFAULT_DEVICE_TREE="st/stm32h743i-custom"
7
CONFIG_OF_LIBFDT_OVERLAY=y
8
9
CONFIG_SYS_LOAD_ADDR=0x24008000
10
CONFIG_SYS_TEXT_BASE=0x08000000   #internal mcu flash
11
CONFIG_TEXT_BASE=0x08000000
12
13
CONFIG_SYS_SDRAM_BASE=0x24000000  #dram_1
14
CONFIG_SYS_SDRAM_SIZE=0x00080000
15
16
CONFIG_SKIP_LOWLEVEL_INIT=y
17
CONFIG_SKIP_RELOCATE_UBOOT=y
18
CONFIG_NR_DRAM_BANKS=1
19
20
CONFIG_SYS_DRAM_TEST=y
21
CONFIG_SYS_DRAM_TEST_LEN=0x00010000
22
23
CONFIG_STM32H7=y
24
CONFIG_TARGET_STM32H743_EVAL=y
25
CONFIG_DISTRO_DEFAULTS=y
26
CONFIG_BOOTDELAY=3
27
CONFIG_AUTOBOOT_KEYED=y
28
CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n"
29
CONFIG_AUTOBOOT_STOP_STR=" "
30
CONFIG_DEFAULT_FDT_FILE="stm32h743i-custom"
31
CONFIG_SYS_CBSIZE=256
32
CONFIG_SYS_PBSIZE=282
33
# CONFIG_DISPLAY_CPUINFO is not set
34
CONFIG_SYS_PROMPT="U-Boot > "
35
CONFIG_CMD_GPT=y
36
CONFIG_CMD_MMC=y
37
# CONFIG_CMD_SETEXPR is not set
38
CONFIG_CMD_CACHE=y
39
CONFIG_CMD_TIMER=y
40
CONFIG_CMD_EXT4_WRITE=y
41
# CONFIG_ISO_PARTITION is not set
42
CONFIG_OF_CONTROL=y
43
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
44
CONFIG_NO_NET=y
45
CONFIG_STM32_SDMMC2=y
46
# CONFIG_PINCTRL_FULL is not set
stm32h743-custom.c:
1
// SPDX-License-Identifier: GPL-2.0+
2
/*
3
 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
4
 * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
5
 */
6
7
#include <dm.h>
8
#include <init.h>
9
#include <log.h>
10
#include <asm/global_data.h>
11
12
DECLARE_GLOBAL_DATA_PTR;
13
14
int dram_init(void)
15
{
16
  struct udevice *dev;
17
  int ret;
18
19
  ret = uclass_get_device(UCLASS_RAM, 0, &dev);
20
  if (ret) {
21
    debug("DRAM init failed: %d\n", ret);
22
    return ret;
23
  }
24
25
  if (fdtdec_setup_mem_size_base() != 0)
26
    ret = -EINVAL;
27
28
  return ret;
29
}
30
31
int dram_init_banksize(void)
32
{
33
  fdtdec_setup_memory_banksize();
34
35
  return 0;
36
}
37
38
int board_init(void)
39
{
40
  return 0;
41
}
stm32h743-custom.h:
1
/* SPDX-License-Identifier: GPL-2.0+ */
2
/*
3
 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
4
 * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
5
 */
6
7
#ifndef __CONFIG_H
8
#define __CONFIG_H
9
10
#include <config.h>
11
#include <linux/sizes.h>
12
13
#define CFG_SYS_BOOTMAPSZ    SZ_128K
14
#define CFG_SYS_FLASH_BASE    0x08000000
15
16
#define CFG_SYS_HZ_CLOCK    1000000
17
18
#define BOOT_TARGET_DEVICES(func) \
19
  func(MMC, mmc, 0)
20
21
#include <config_distro_bootcmd.h>
22
#define CFG_EXTRA_ENV_SETTINGS        \
23
      "kernel_addr_r=0xD0008000\0"    \
24
      "fdtfile=stm32h743i-eval.dtb\0"  \
25
      "fdt_addr_r=0xD0408000\0"    \
26
      "scriptaddr=0xD0418000\0"    \
27
      "pxefile_addr_r=0xD0428000\0" \
28
      "ramdisk_addr_r=0xD0438000\0"    \
29
      BOOTENV
30
31
#endif /* __CONFIG_H */
stm32h743-custom.dts:
1
/dts-v1/;
2
#include "stm32h743.dtsi"
3
#include "stm32h7-pinctrl.dtsi"
4
5
/ {
6
  model = "STMicroelectronics STM32H743i-EVAL board";
7
  compatible = "st,stm32h743i-eval", "st,stm32h743";
8
9
  chosen {
10
    bootargs = "root=/dev/ram";
11
    stdout-path = "serial0:115200n8";
12
  };
13
14
  /* AXI‑SRAM (512 KB) */
15
  memory {
16
    device_type = "memory";
17
    reg = <0x24000000 0x00080000>;
18
    status = "okay";
19
  };
20
21
  aliases {
22
    serial0 = &usart2;
23
  };
24
};
25
26
27
&clk_hse {
28
  clock-frequency = <25000000>;
29
  st,bypass;
30
};
31
32
33
&rtc {
34
  status = "okay";
35
};
36
37
&mac {
38
  status = "disabled";
39
  pinctrl-0 = <&ethernet_rmii>;
40
  pinctrl-names = "default";
41
  phy-mode = "rmii";
42
  phy-handle = <&phy0>;
43
44
  mdio0 {
45
    #address-cells = <1>;
46
    #size-cells = <0>;
47
    compatible = "snps,dwmac-mdio";
48
    phy0: ethernet-phy@0 {
49
      reg = <0>;
50
    };
51
  };
52
};
53
54
&sdmmc1 {
55
  pinctrl-names = "default", "opendrain", "sleep";
56
  pinctrl-0 = <&sdmmc1_b4_pins_a &sdmmc1_dir_pins_a>;
57
  pinctrl-1 = <&sdmmc1_b4_od_pins_a &sdmmc1_dir_pins_a>;
58
  pinctrl-2 = <&sdmmc1_b4_sleep_pins_a &sdmmc1_dir_sleep_pins_a>;
59
  broken-cd;
60
  st,sig-dir;
61
  st,neg-edge;
62
  st,use-ckin;
63
  bus-width = <4>;
64
  status = "okay";
65
};
66
67
&usart2 {
68
  pinctrl-0 = <&usart2_tx_pin &usart2_rx_pin>;
69
  pinctrl-names = "default";
70
  status = "okay";
71
};
72
73
&pinctrl {
74
  usart2_tx_pin: usart2-tx {
75
    pins {
76
      pinmux = <STM32_PINMUX('A', 2, AF7)>; /* USART2_TX PA2 */
77
      bias-disable;
78
      drive-push-pull;
79
      slew-rate = <3>;
80
    };
81
  };
82
83
  usart2_rx_pin: usart2-rx {
84
    pins {
85
      pinmux = <STM32_PINMUX('D', 6, AF7)>; /* USART2_RX PD6 */
86
      bias-disable;
87
    };
88
  };
89
}

von Niklas G. (erlkoenig) Benutzerseite


Lesenswert?

1
pc : 08000a86
Dann schau doch mal diese Codestelle macht, und diese ebenso:
1
lr : 0800bf37
Gibt dein Debugger keinen Backtrace aus?

: Bearbeitet durch User
von Wastl (hartundweichware)


Lesenswert?

Daniel S. schrieb:
> Hey,

Fuck!

Du bist hier lang genug dabei um zu wissen dass man längere
Sources als Anhang postet, nicht im fortlaufenden Text.

Fuck!

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.
Lade...