Exemplo n.º 1
0
        /// <summary>
        /// Function to transmit the application for flash
        /// </summary>
        private static Boolean TransmitAPP()
        {
            Byte[] imageData;
              ImageHeader ackHeader = new ImageHeader();

              try
              {
            // Now Send the application image that will be written to flash
            //Console.WriteLine("Sending the Application image");
            imageData = FileIO.GetFileData(cmdParams.APPFileName);
            ackHeader.magicNum = ((UInt32)MagicFlags.UBL_MAGIC_BINARY_BOOT);
            ackHeader.startAddr = cmdParams.APPStartAddr;
            ackHeader.byteCnt = (UInt32) imageData.Length;
            ackHeader.loadAddr = cmdParams.APPLoadAddr;
            ackHeader.flashAddr = cmdParams.APPFlashBlock;
            Console.WriteLine("\nFlashing application " + cmdParams.APPFileName +" (" + imageData.Length +" bytes)\n");

            if (!TransmitImage(imageData, ackHeader))
            {
              return false;
            }

            DisplayProgressBar(ackHeader.byteCnt, 4096, "Programming application into flash...", "Verifying...", "Application programming complete");

            return true;
              }
              catch (ObjectDisposedException e)
              {
            Console.WriteLine(e.StackTrace);
            throw e;
              }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Function to transmit the application code via the SFT, which is now 
        /// running on the device.  This code is specific to the supplied SFT.
        /// If the the TI supplied SFT is modified or a different boot loader is
        /// used, this code will need to be modified.
        /// </summary>
        private static Boolean TransmitImage(Byte[] imageData, ImageHeader ackHeader)
        {
            ProgressBar progressBar;
              UInt32 blockCnt;

              try
              {
            // Console.WriteLine("Waiting for SENDIMG sequence...");
            if (!SerialIO.waitForSequence("SENDIMG\0", "BOOTUBL\0", MySP, cmdParams.verbose))
            {
              Console.Write("UART response didnt match\n");
              return false;
            }

            // Output 36 Bytes for the ACK sequence and header
            // 8 bytes acknowledge sequence = "    ACK\0"
            MySP.Write("    ACK\0");
            // 8 bytes of magic number
            MySP.Write(String.Format("{0:X8}", ackHeader.magicNum));
            // 8 bytes of binary execution address = ASCII string of 8 hex characters
            MySP.Write(String.Format("{0:X8}", ackHeader.startAddr));
            // 8 bytes of data size = ASCII string of 8 hex characters
            MySP.Write(String.Format("{0:X8}", ackHeader.byteCnt));
            // 8 bytes of binary load address = ASCII string of 8 hex characters
            MySP.Write(String.Format("{0:X8}", ackHeader.loadAddr));
            // 8 bytes of flash address = ASCII string of 8 hex characters
            MySP.Write(String.Format("{0:X8}", ackHeader.flashAddr));
            // 4 bytes of constant zeros = "0000"
            MySP.Write("0000");

            //Console.WriteLine("ACK command sent. Waiting for BEGIN command... ");

            // Wait for the ^^BEGIN\0 sequence
            if (!SerialIO.waitForSequence("  BEGIN\0", "BOOTUBL\0", MySP, cmdParams.verbose))
            {
              return false;
            }
            //Console.WriteLine("BEGIN commmand received.");

            // Send the image data
            progressBar = new ProgressBar();
            progressBar.Update(0.0,"Sending image over UART...");
            blockCnt = ackHeader.byteCnt/128;
            for (int i = 0; i < (blockCnt*128); i+=128)
            {
              MySP.Write(imageData, i, 128);
              progressBar.Percent = (((Double)(i+1))/ackHeader.byteCnt);
            }

            // Write last (possibly partial) block
            MySP.Write(imageData, (Int32) (blockCnt*128),(Int32) (ackHeader.byteCnt - (blockCnt*128)) );
            progressBar.Update(100.0,"Image data transmitted over UART.");

            //Console.WriteLine("Waiting for DONE...");

            // Wait for first ^^^DONE\0 to indicate data received
            if (!SerialIO.waitForSequence("   DONE\0", "BOOTUBL\0", MySP, cmdParams.verbose))
            {
              return false;
            }
            //Console.WriteLine("DONE received.  All bytes of image data received...");
              }
              catch (ObjectDisposedException e)
              {
            Console.WriteLine(e.StackTrace);
            throw e;
              }
              return true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Function to transmit the UBL and application for flash
        /// </summary>
        private static Boolean TransmitUBLandAPP()
        {
            Byte[] imageData;
              ImageHeader ackHeader = new ImageHeader();

              try
              {
            // First send the UBL image that will be written to flash
            //Console.WriteLine("Sending the UBL image");
            // Now Send the application image that will be written to flash
            imageData = FileIO.GetFileData(cmdParams.UBLFileName);
            ackHeader.magicNum = ((UInt32)cmdParams.UBLMagicFlag);
            ackHeader.startAddr = cmdParams.UBLStartAddr;
            ackHeader.byteCnt = (UInt32) imageData.Length;
            ackHeader.loadAddr = 0x0020;

            Console.WriteLine("\nFlashing UBL " + cmdParams.UBLFileName +" (" + imageData.Length +" bytes) at 0x00000000\n");

            if (!TransmitImage(imageData, ackHeader))
            {
              return false;
            }

            // Update status bar
            DisplayProgressBar(ackHeader.byteCnt, 4096, "Programming UBL into flash...", "Verifying...", "UBL programming complete");

            // Now Send the application image that will be written to flash
            imageData = FileIO.GetFileData(cmdParams.APPFileName);
            ackHeader.magicNum = (UInt32)cmdParams.APPMagicFlag;
            ackHeader.startAddr = cmdParams.APPStartAddr;
            ackHeader.byteCnt = (UInt32) imageData.Length;
            ackHeader.loadAddr = cmdParams.APPLoadAddr;    // Not used here, but this is what RBL assumes
            Console.WriteLine("\nFlashing application " + cmdParams.APPFileName +" (" + imageData.Length +" bytes)\n");

            // Transmit the data
            if (!TransmitImage(imageData, ackHeader))
            {
              return false;
            }

            // Update status bar as SPI is being flashed
            DisplayProgressBar(ackHeader.byteCnt, 4096, "Programming application into flash...", "Verifying...", "Application programming complete");

            return true;
              }
              catch (ObjectDisposedException e)
              {
            Console.WriteLine(e.StackTrace);
            throw e;
              }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Function to transmit the UBL and application for flash
        /// </summary>
        private static Boolean TransmitAPP()
        {
            Byte[] imageData;
              ImageHeader ackHeader = new ImageHeader();

              try
              {
            // Now Send the application image that will be written to flash
            Console.WriteLine("Sending the Application image");
            imageData = FileIO.GetFileData(cmdParams.APPFileName);
            ackHeader.magicNum = ((UInt32)MagicFlags.UBL_MAGIC_BINARY_BOOT);
            ackHeader.startAddr = cmdParams.APPStartAddr;
            ackHeader.byteCnt = (UInt32) imageData.Length;
            ackHeader.loadAddr = cmdParams.APPLoadAddr;

            if (!TransmitImage(imageData, ackHeader))
            {
              return false;
            }
            // ^^^DONE\0 that indicates that application flashing is complete
            if (!SerialIO.waitForSequence("   DONE\0", "BOOTUBL\0", MySP, true))
              return false;

            return true;
              }
              catch (ObjectDisposedException e)
              {
            Console.WriteLine(e.StackTrace);
            throw e;
              }
        }