Main Site Documentation

Flashing DL40 with G400


#1

While trying to flash my DL40 on a socket with the connector on * the procedure stops on [quote]Connecting…[/quote]
I hope that I’m missing something but I can’t figure out what.
LPC1113F is different than the LPC1111 but I guessed that was ok.
NXP.Frequency.MHz_72 and NXP.Frequency.MHz_168 didn’t make the difference and I also don’t know which one I should use.

  
        public static Thread flashThread;
        public static InterruptPort _button;
        public static byte[] binFile = Resources.GetBytes(Resources.BinaryResources.DL40);
        public static SerialPort serial;
        public static GT.Interfaces.DigitalOutput reset;
        public static GT.Interfaces.DigitalOutput loader;
        public static bool doneFlash = true;
        void ProgramStarted()
        {
            var socketNumber = 9;
            loader = new GT.Interfaces.DigitalOutput(Gadgeteer.Socket.GetSocket(socketNumber, true, null, null), GT.Socket.Pin.Six, true, null);
            reset = new GT.Interfaces.DigitalOutput(Gadgeteer.Socket.GetSocket(socketNumber, true, null, null), GT.Socket.Pin.Seven, true, null);

            _button = new InterruptPort((Cpu.Pin)24, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
            _button.OnInterrupt += _button_OnInterrupt;

            serial = new SerialPort(Gadgeteer.Socket.GetSocket(socketNumber, true, null, null).SerialPortName, 9600, Parity.None, 8, StopBits.One);
            serial.Open();
        }

        void _button_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            if (doneFlash)
            {
                doneFlash = false;
                flashThread = new Thread(DL40FirmwareThread);
                flashThread.Start();
            }        
        }
        static void DL40FirmwareThread()
        {
            Debug.Print("Beginning chip reflash...");
            loader.Write(false);
            Thread.Sleep(100);
            reset.Write(false);
            Thread.Sleep(100);
            reset.Write(true);
            Thread.Sleep(400);
            NXPFlashLoader.CommunicationInterface com = new SerialPortToNXP(serial);
            NXP.Programmer p = new NXP.Programmer(com, NXP.Chips.LPC1111, NXP.Frequency.MHz_72);
            Debug.Print("Connecting...");
            p.Connect();
            Debug.Print("Connected!");
            Debug.Print("Erasing...");
            p.EraseAll();
            Debug.Print("Erased!");
            Debug.Print("Converting File...");
            p.SelectDownloadBuffer(binFile, 0, binFile.Length);
            Debug.Print("Converted!");
            Debug.Print("Downloading...");
            p.Download();
            Debug.Print("Downloaded!");
            Debug.Print("Verifying...");
            p.Verify();
            Debug.Print("Verified!");
            Debug.Print("Board Flash Complete!");
            doneFlash = true;
        }
}

The thread hangs on com.read(cmdBuffer, 0 , 1, TIMEOUT); :


      public void Connect(){
        byte[] dummyBuffer;
        com.Initialize();
        com.Purge();
        // send "?"
        com.Write(Encoding.UTF8.GetBytes("?"), 0, 1);
        // Read "Synchronized"
        long initialTime = DateTime.Now.Ticks / 10000;
        do {
          com.Read(cmdBuffer, 0, 1, TIMEOUT);
          if (cmdBuffer[0] == (byte)'S')
            break;
        } while (((DateTime.Now.Ticks / 10000) - initialTime) <= TIMEOUT);
}

I hope someone see’s my mistake. Thanks in advance :slight_smile:


#2

As a developer I often have a moment that when you ask somebody to come have a look because you can’t figure something out. And from the moment that you are explaining your problem you figured out what went wrong?

This just happened but then virtually. :-[

I mixed up the reset and loader with pin numbers ::slight_smile: