gpt4 book ai didi

http - mbed:建立网络连接后访问 SD 卡时出现 HardFault 错误

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:18 24 4
gpt4 key购买 nike

我想结合一个 HTTP 客户端和一个 SD 卡读卡器。我的目标是从服务器下载文件并将该文件保存在 SD 卡上。不幸的是,由于硬故障 0x80FF013D,我卡在了路上。

我已经把代码分解了,总结一下:

  • 网络通信(GET 命令)单独运行良好
  • SD 卡访问(读取和写入)单独运行良好
  • 在建立网络连接之前 SD 卡访问工作正常
  • 硬故障发生,当我建立网络连接后访问SD卡

核心信息:

  • 操作系统:MBED OS5
  • IDE:MBED CLI v1.8.2
  • 主控:NUCLEO-F746ZG
  • SD 读卡器:带有 Transcend 2GB microSD(FAT 格式)的 CATALEX MicroSD 卡适配器

图书馆:

带硬故障的串行输出:

[NWKH] Connecting to network...
[NWKH] Connected to the network
[NWKH] IP address: 192.168.188.29
Test SD-Card

++ MbedOS Fault Handler ++

FaultType: HardFault

Context:
R0 : 20000400
R1 : BFF39B82
R2 : 08025B6A
R3 : 00000003
R4 : 00000000
R5 : 2000FA34
R6 : 84551677
R7 : 7FFFFC00
R8 : 00000003
R9 : 08025B6A
R10 : 2000FA34
R11 : 00000000
R12 : 08013E6D
SP : 2000F9F8
LR : 0801A8E7
PC : A0000000
xPSR : 210B0000
PSP : 2000F990
MSP : 2004FFC0
CPUID: 410FC271
HFSR : 40000000
MMFSR: 00000001
BFSR : 00000000
UFSR : 00000000
DFSR : 0000000B
AFSR : 00000000
Mode : Thread
Priv : Privileged
Stack: PSP

-- MbedOS Fault Handler --

++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x8012A7B
Error Value: 0xA0000000
Current Thread: Id: 0x2000DA34 Entry: 0x8012BEB StackSize: 0x2000 StackMem: 0x2000DA78 SP: 0x2004FF58
For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF013D
-- MbedOS Error Info --

我从 mbed https://os.mbed.com/teams/sandbox/code/http-example/file/2efadc4d8784/source/main-http-socket-reuse.cpp/shortlog/ 的 http-example 开始

并从 sd 卡文件系统示例中添加了一些内容 https://os.mbed.com/cookbook/SD-Card-File-System

main-http.cpp

#include "select-demo.h"

#if DEMO == DEMO_HTTP

#include "mbed.h"
#include "http_request.h"
#include "network-helper.h"
#include "mbed_mem_trace.h"
#include "SDBlockDevice.h"
#include "FATFileSystem.h"
#include "DebouncedIn.h"

#define SD_MOUNT_PATH "sd"
#define FULL_UPDATE_FILE_PATH "/" SD_MOUNT_PATH "/" MBED_CONF_APP_UPDATE_FILE

SDBlockDevice sd(MBED_CONF_APP_SD_CARD_MOSI, MBED_CONF_APP_SD_CARD_MISO,
MBED_CONF_APP_SD_CARD_SCK, MBED_CONF_APP_SD_CARD_CS);
FATFileSystem fs(SD_MOUNT_PATH);

NetworkInterface* network;
DebouncedIn btn(USER_BUTTON);

FILE* file;

int main()
{
/*------Init SD-Card-----------*/
int r;
//Init
if ((r = sd.init()) != 0) {
printf("Could not initialize SD driver (%d)\n", r);
return 1;
}

//Mount
if ((r = fs.mount(&sd)) != 0) {
printf("Could not mount filesystem, is the SD card formatted as FAT? (%d)\n", r);
return 1;
}

/*------Init Network-----------*/
network = connect_to_default_network_interface();
if (!network)
{
printf("Cannot connect to the network, see serial output\n");
return 1;
}

//Write
printf("Test SD-Card\n");
char testbuffer2[] = { 'a' , 'b' , 'c' };
file = fopen("/sd/test.bin", "wb");
fwrite("abc",1,3,file);
//fwrite(testbuffer2,1,sizeof(testbuffer2),file);
fclose(file);

//Hauptschleife
while(1)
{
//Buttondruck
if (btn.rising())
{
printf("Update wird gesucht, bitte warten\n");
}
}
}

#endif

mbed_app.json

{
"config": {
"main-stack-size": {
"value": 8192
},

"update_file": {
"help": "Path to the application update binary on the SD card",
"value": "\"update.bin\""
},

"sd_card_mosi": {
"help": "MCU pin connected to the SD card's SPI MOSI pin",
"value": "D11"
},
"sd_card_miso": {
"help": "MCU pin connected to the SD card's SPI MISO pin",
"value": "D12"
},
"sd_card_sck": {
"help": "MCU pin connected to the SD card's SPI SCK pin",
"value": "D13"
},
"sd_card_cs": {
"help": "MCU pin connected to the SD card's SPI CS pin",
"value": "D10"
}
},
"macros": [
"MBEDTLS_MPI_MAX_SIZE=1024",
"MBEDTLS_MPI_WINDOW_SIZE=1",
"MBEDTLS_USER_CONFIG_FILE=\"mbedtls_entropy_config.h\"",
"MBEDTLS_TEST_NULL_ENTROPY",
"MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES",
"MBED_HEAP_STATS_ENABLED=1"
],
"target_overrides": {
"*": {
"platform.stdio-baud-rate": 115200,
"platform.stdio-convert-newlines": true,
"mbed-mesh-api.6lowpan-nd-channel-page": 0,
"mbed-mesh-api.6lowpan-nd-channel": 12,
"mbed-trace.enable": 1,
"platform.error-hist-enabled": 1,
"mbed-http.http-buffer-size": 2048,
"nsapi.default-wifi-security": "WPA_WPA2",
"nsapi.default-wifi-ssid": "\"SSID\"",
"nsapi.default-wifi-password": "\"Password\""
}
}
}

我已经阅读了“分析 Mbed 操作系统故障转储”教程 -> https://os.mbed.com/docs/v5.8/tutorials/analyzing-mbed-os-crash-dump.html ,
但我仍然不知道我能做些什么来找到硬故障的原因。

  • 错误状态:“0x80FF013D”表示“硬故障异常”
  • HFSR:40000000 表示“强制硬故障”
  • MMFSR:00000001 表示“处理器试图从不允许执行的位置获取指令。”
  • UFSR:00000000 表示“一切都好”
  • BFSR:00000000 表示“一切都好”

我会很感激一些帮助。提前致谢。

最佳答案

此板有冲突引脚 D11。它由以太网和您的 SPI 使用。您需要使用其他 SPI 引脚或遵循 guide从 mbed 站点到修复板:

If you use both SPI and Ethernet You have to patch the NUCLEO board on the back side:

  1. remove SB121 and close SB122 solder bridges. This willconnect PB_5 to D11 instead of PA_7.
  2. Overwrite the d11_configuration by using the mbed_app.json file and use PB_5 (instead of PA_7 default value).

关于http - mbed:建立网络连接后访问 SD 卡时出现 HardFault 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53432839/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com