Gsm shield and SD card

Hello I need some help.

I have a Arduino Ethernet and an Arduino Gsm shield, the official one.
I am trying to start the gsm shield, after the SD card and create a file on the sd card, but it blocks.
Can you check what is wrong on this code/

Thank you.

///////////////////// Library and initializations //////////////////////////////
#include <GSM.h>
#include <SD.h>

GSM gsmAccess;
GSMVoiceCall vcs;
GSM_SMS sms;

GSM3ShieldV1DirectModemProvider modemAccess;

char charbuffer[20];

///////////////PIN Number of the SIM card, phone numbers and SMS////////////////

#define PINNUMBER ""

File myFile;

void setup()
  Serial.println("Network TEST");
  Serial.println("DATA.txt created");


void loop()

void start_gsm()
  Serial.println("Waiting for the GSM Shield...");
  boolean notConnected = true;
      notConnected = false;
      Serial.println("Not connected");
  Serial.println("GSM Shield initialized");

void start_sd()
    Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");  

void creat_file()
   //Creat the new file  
  Serial.println("Creating DATA.txt...");
  myFile ="DATA.txt", FILE_WRITE);
  Serial.println("DATA.txt is created");

sometimes give me this:

øøøøNetwork TEST
Waiting for the GSM Shield…
GSM Shield initialized


I cannot help you but would like to know if you make it work as I would also like to use Arduino Ethernet + GSM shield.

It appears you may be running out of SRAM. The symptoms could range from garbage on the serial monitor to a reboot of the Arduino.

Try adding this function and call it before calling each device setup function.

int freeRam() {
  extern int __heap_start,*__brkval;
  int v;
  return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int) __brkval);  

edit: Then use it like this:

Serial.print(F("Free RAM: "));

It will not show zero if you run out of SRAM. It will show a negative or an unrealistic large value.

Can you test the code? It start to loop.