我想结合使用HTTP客户端和SD卡阅读器。我的目标是从服务器下载文件并将该文件保存在SD卡上。不幸的是,由于硬故障0x80FF013D,我陷入了困境。
我没有分解代码并得到总结:
核心信息:
图书馆:
开始使用http-example[NWKH]正在连接网络...
[NWKH]已连接到网络
[NWKH] IP地址:192.168.188.29
测试SD卡++ MbedOS故障处理程序++
FaultType:HardFault
上下文:
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
模式:螺纹
特权:特权
堆栈:PSP-MbedOS故障处理程序-
++ MbedOS错误信息++
错误状态:0x80FF013D代码:317模块:255
错误消息:故障异常
位置:0x8012A7B
错误值:0xA0000000
当前线程:ID:0x2000DA34条目:0x8012BEB堆栈大小:0x2000堆栈内存:0x2000DA78 SP:0x2004FF58
有关更多信息,请访问:https://armmbed.github.io/mbedos-error/?error=0x80FF013D
-MbedOS错误信息-
并从sd卡文件系统示例中添加了一些内容 https://os.mbed.com/cookbook/SD-Card-File-System
#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
{
"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 OS故障转储”的教程-> https://os.mbed.com/docs/v5.8/tutorials/analyzing-mbed-os-crash-dump.html,
但是我仍然不知道该怎么办才能找到发生硬故障的原因。
我将不胜感激。预先感谢。
答案 0 :(得分:0)
此板具有冲突引脚D11。以太网和您的SPI都使用它。您需要使用其他SPI引脚或从mbed网站遵循guide来固定电路板:
如果同时使用 SPI和以太网,则必须在背面打补丁NUCLEO板:
- 卸下SB121并关闭SB122焊桥。这将 将PB_5连接到D11而不是PA_7。
- 使用mbed_app.json文件覆盖d11_configuration并使用PB_5(而不是PA_7的默认值)。