mbed: HardFault Error when accessing SD-Card after building up network connection











up vote
1
down vote

favorite












I want to combine a HTTP-Client and a SD-Card-Reader. My goal is to download a file from a server and save that file on the SD-Card. Unfortunately Im stuck on the way, because of an Hard Fault 0x80FF013D.



I haven broken down the code and recognized in summary:




  • network communication (GET-command) works fine solo

  • SD-Card access (read and write) works fine solo

  • SD-Card access works fine before building up the network connection

  • Hard Fault occures, when I access the SD-Card after building up the network connection


Core-Infos:




  • OS: MBED OS5

  • IDE: MBED CLI v1.8.2

  • MC: NUCLEO-F746ZG

  • SD-Card Reader: CATALEX MicroSD Card Adapter with Transcend 2GB microSD (FAT formatted)


Libraries:




  • mbed-os
    https://github.com/ARMmbed/mbed-os/#e1bea44212b8275f7d8ce7253e758c2e25c57482

  • sd-driver https://github.com/ARMmbed/sd-driver/#a8c85d30af86a7431d85dee02d133d60dd386406


Serial Output with HardFault:




[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 --




I have started with the http-example from mbed https://os.mbed.com/teams/sandbox/code/http-example/file/2efadc4d8784/source/main-http-socket-reuse.cpp/shortlog/



and added some stuff from the sd card file system example
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 outputn");
return 1;
}

//Write
printf("Test SD-Cardn");
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 wartenn");
}
}
}

#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""
}
}
}


I have already read the Tutorial for "Analyzing Mbed OS crash dump" -> https://os.mbed.com/docs/v5.8/tutorials/analyzing-mbed-os-crash-dump.html,

but I have still no idea what I can do, to find the reason for the Hard Fault.




  • Error Status: "0x80FF013D" means "Hard Fault exception"

  • HFSR: 40000000 means "Forced Hard Fault"

  • MMFSR: 00000001 means "The processor attempted an instruction fetch from a location that does not permit execution."

  • UFSR: 00000000 means "everything is good"

  • BFSR: 00000000 means "everything is good"


I would appreciate some help. Thanks in advance.










share|improve this question


























    up vote
    1
    down vote

    favorite












    I want to combine a HTTP-Client and a SD-Card-Reader. My goal is to download a file from a server and save that file on the SD-Card. Unfortunately Im stuck on the way, because of an Hard Fault 0x80FF013D.



    I haven broken down the code and recognized in summary:




    • network communication (GET-command) works fine solo

    • SD-Card access (read and write) works fine solo

    • SD-Card access works fine before building up the network connection

    • Hard Fault occures, when I access the SD-Card after building up the network connection


    Core-Infos:




    • OS: MBED OS5

    • IDE: MBED CLI v1.8.2

    • MC: NUCLEO-F746ZG

    • SD-Card Reader: CATALEX MicroSD Card Adapter with Transcend 2GB microSD (FAT formatted)


    Libraries:




    • mbed-os
      https://github.com/ARMmbed/mbed-os/#e1bea44212b8275f7d8ce7253e758c2e25c57482

    • sd-driver https://github.com/ARMmbed/sd-driver/#a8c85d30af86a7431d85dee02d133d60dd386406


    Serial Output with HardFault:




    [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 --




    I have started with the http-example from mbed https://os.mbed.com/teams/sandbox/code/http-example/file/2efadc4d8784/source/main-http-socket-reuse.cpp/shortlog/



    and added some stuff from the sd card file system example
    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 outputn");
    return 1;
    }

    //Write
    printf("Test SD-Cardn");
    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 wartenn");
    }
    }
    }

    #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""
    }
    }
    }


    I have already read the Tutorial for "Analyzing Mbed OS crash dump" -> https://os.mbed.com/docs/v5.8/tutorials/analyzing-mbed-os-crash-dump.html,

    but I have still no idea what I can do, to find the reason for the Hard Fault.




    • Error Status: "0x80FF013D" means "Hard Fault exception"

    • HFSR: 40000000 means "Forced Hard Fault"

    • MMFSR: 00000001 means "The processor attempted an instruction fetch from a location that does not permit execution."

    • UFSR: 00000000 means "everything is good"

    • BFSR: 00000000 means "everything is good"


    I would appreciate some help. Thanks in advance.










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I want to combine a HTTP-Client and a SD-Card-Reader. My goal is to download a file from a server and save that file on the SD-Card. Unfortunately Im stuck on the way, because of an Hard Fault 0x80FF013D.



      I haven broken down the code and recognized in summary:




      • network communication (GET-command) works fine solo

      • SD-Card access (read and write) works fine solo

      • SD-Card access works fine before building up the network connection

      • Hard Fault occures, when I access the SD-Card after building up the network connection


      Core-Infos:




      • OS: MBED OS5

      • IDE: MBED CLI v1.8.2

      • MC: NUCLEO-F746ZG

      • SD-Card Reader: CATALEX MicroSD Card Adapter with Transcend 2GB microSD (FAT formatted)


      Libraries:




      • mbed-os
        https://github.com/ARMmbed/mbed-os/#e1bea44212b8275f7d8ce7253e758c2e25c57482

      • sd-driver https://github.com/ARMmbed/sd-driver/#a8c85d30af86a7431d85dee02d133d60dd386406


      Serial Output with HardFault:




      [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 --




      I have started with the http-example from mbed https://os.mbed.com/teams/sandbox/code/http-example/file/2efadc4d8784/source/main-http-socket-reuse.cpp/shortlog/



      and added some stuff from the sd card file system example
      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 outputn");
      return 1;
      }

      //Write
      printf("Test SD-Cardn");
      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 wartenn");
      }
      }
      }

      #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""
      }
      }
      }


      I have already read the Tutorial for "Analyzing Mbed OS crash dump" -> https://os.mbed.com/docs/v5.8/tutorials/analyzing-mbed-os-crash-dump.html,

      but I have still no idea what I can do, to find the reason for the Hard Fault.




      • Error Status: "0x80FF013D" means "Hard Fault exception"

      • HFSR: 40000000 means "Forced Hard Fault"

      • MMFSR: 00000001 means "The processor attempted an instruction fetch from a location that does not permit execution."

      • UFSR: 00000000 means "everything is good"

      • BFSR: 00000000 means "everything is good"


      I would appreciate some help. Thanks in advance.










      share|improve this question













      I want to combine a HTTP-Client and a SD-Card-Reader. My goal is to download a file from a server and save that file on the SD-Card. Unfortunately Im stuck on the way, because of an Hard Fault 0x80FF013D.



      I haven broken down the code and recognized in summary:




      • network communication (GET-command) works fine solo

      • SD-Card access (read and write) works fine solo

      • SD-Card access works fine before building up the network connection

      • Hard Fault occures, when I access the SD-Card after building up the network connection


      Core-Infos:




      • OS: MBED OS5

      • IDE: MBED CLI v1.8.2

      • MC: NUCLEO-F746ZG

      • SD-Card Reader: CATALEX MicroSD Card Adapter with Transcend 2GB microSD (FAT formatted)


      Libraries:




      • mbed-os
        https://github.com/ARMmbed/mbed-os/#e1bea44212b8275f7d8ce7253e758c2e25c57482

      • sd-driver https://github.com/ARMmbed/sd-driver/#a8c85d30af86a7431d85dee02d133d60dd386406


      Serial Output with HardFault:




      [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 --




      I have started with the http-example from mbed https://os.mbed.com/teams/sandbox/code/http-example/file/2efadc4d8784/source/main-http-socket-reuse.cpp/shortlog/



      and added some stuff from the sd card file system example
      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 outputn");
      return 1;
      }

      //Write
      printf("Test SD-Cardn");
      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 wartenn");
      }
      }
      }

      #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""
      }
      }
      }


      I have already read the Tutorial for "Analyzing Mbed OS crash dump" -> https://os.mbed.com/docs/v5.8/tutorials/analyzing-mbed-os-crash-dump.html,

      but I have still no idea what I can do, to find the reason for the Hard Fault.




      • Error Status: "0x80FF013D" means "Hard Fault exception"

      • HFSR: 40000000 means "Forced Hard Fault"

      • MMFSR: 00000001 means "The processor attempted an instruction fetch from a location that does not permit execution."

      • UFSR: 00000000 means "everything is good"

      • BFSR: 00000000 means "everything is good"


      I would appreciate some help. Thanks in advance.







      http sd-card mbed nucleo






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 14:11









      DanielS

      62




      62





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432839%2fmbed-hardfault-error-when-accessing-sd-card-after-building-up-network-connectio%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432839%2fmbed-hardfault-error-when-accessing-sd-card-after-building-up-network-connectio%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What visual should I use to simply compare current year value vs last year in Power BI desktop

          Alexandru Averescu

          Trompette piccolo