Main Site Documentation

Cobra II + CP7 not programmable after initialization


#1

Hi, today I have following problem. Every time after I configure the CP7 I can’t deploy a program or the debugger get stuck at startup. Somtimes the display shows “ASSERT”, the cobra reboots unexpactetly and so on.

I have nothing connected to the Cobra II NET except the display, only the RGB ones.

I do a complete erase, reflash it with the current firmware etc.

Then I run following program:


using Microsoft.SPOT;
using System.Threading;
using GHI.Premium.Hardware;
using Microsoft.SPOT.Hardware;
namespace TestG120_2
{
    public class Program
    {
        public static void Main()
        {
            Debug.Print("Start configuration");

            Configuration.LCD.Configurations lcdConfig = new Configuration.LCD.Configurations();

            lcdConfig.Width = 800;
            lcdConfig.Height = 480;

            lcdConfig.OutputEnableIsFixed = true;
            lcdConfig.OutputEnablePolarity = true;

            lcdConfig.HorizontalSyncPolarity = true;
            lcdConfig.VerticalSyncPolarity = true;
            lcdConfig.PixelPolarity = false;

            lcdConfig.HorizontalSyncPulseWidth = 1;
            lcdConfig.HorizontalBackPorch = 46;
            lcdConfig.HorizontalFrontPorch = 16;
            lcdConfig.VerticalSyncPulseWidth = 1;
            lcdConfig.VerticalBackPorch = 23;
            lcdConfig.VerticalFrontPorch = 7;

            lcdConfig.PixelClockRateKHz = 24000;

            // Set config
            if (Configuration.LCD.Set(lcdConfig))
            {
                Debug.Print("Safe configuration and reboot");
                PowerState.RebootDevice(false);
            }

            Debug.Print("Hallo world");
            Thread.Sleep(Timeout.Infinite);
        }
    }
}

First it runs normal till you reach the section for the reboot. If you hit F5 to rerun the program the debugger gets stuck or it can’t deploy it any more.

Is the board damaged? its brand new, got it this week.

Something wrong?


#2

Is the same as when I do it in code.


#3

And CP7 is power hungry so you must have a powered hub or power pack connected.


#4

@ andre.m - yes correct I do following

  1. Press all buttons on the board, release reset and open TeraTerm, Press E, Press X send the tinybooter

  2. Fezconfig flash firmware

  3. Fezconfig set display to CP7

  4. Reboot, ok display show the usal text

  5. Start VS2012, start following Program:


using Microsoft.SPOT;
using System.Threading;
namespace TestG120_2
{
    public class Program
    {
        public static void Main()
        {
            Debug.Print("Hallo world");
            Thread.Sleep(Timeout.Infinite);
        }
    }
}

Every time I start the program in the Output window, “Micro Framework Device Deployment” shows:

Now it gets stuck, display shows:
G120
Version: 4.2.11.1
Debug: USB1
LCD 800x480

The funny thing is if I deploy it 2 or 3 times without changing something, he didn’t recognized it. Normaly it display’s that nothing changed no need to increment somthing.

Hopefully someone can help me.

A couple of months befor I I had a G120HDR with the CP7 + sdcard and ethernet module and it worked as it should. So I can’t understand it.

@ Gus I used a 6V 1000ma power supply


#5

Cobra lists 7v to 30v on the board by the connector so why are you using 6v? :slight_smile:


#6

Ok now I use a 12V 2000mA and Fez config is closed after the firmware flash and lcd config.

And nothing changed

@ andre.m no communication is possible sometimes after i hit the reset of the board, windows is saying that it cant recognize the device.


#7

For me in general its wiered that the programmer every time wants to program the board and doesn’t recognize that the program hasn’t changed. Normaly he writes in the output thats nothing has changed. you know what I mean?


#8

Leave all as is but completely disconnect the lcd. Can you program it now?


#9

if it doesn’t, can you ping it?

Make sure you can see TinyCLR. If it is in TinyBooter mode, Click on Advance->Rebooter CLR or using MFDeploy->Debug-> Clear Bootloader Flag


#10

Ok as follows, without the display connected fresh installed tinybooter and firmware all works, I can program it, I can rerun etc. as normal

Ok now I go to fezconfig (no display connected) configure the cp7, restart, hit ping it shows TinyBooter, ok Reboot CLR

After that nothing works. No Ping nothing

Ok I connect the display to see something, it looks normal on the display.

Ping doesn’t work

After waiting a while the display says ASSERT or Buffer OVFLW

Ok next try:

disconnect CP7, reflash TinyBooter and firmware.
connect CP7, fezconfig configure CP7 ok restart - > Ping … TinyCLR
close fezconfig
delete all bin and obj folders
goto VS2012 hello world program
press start
Ok it works

I thought perfect, next program, demo onewire.

Download etc. ok, started, Error,
restarted the program
debugger engine can’t attach etc.
or sometime programming worked but it doesn’t run.
After a while it restarts

Maybe some soldering is wrong and the usb is in conflict with the display?


#11

Now I got a “System.OutOfMemoryException” exception at my hello world program

After stopping Visual studio and open Fezconfig, and hit the ping button. I get

[quote] Pinging…
Failure - Device is not connected or not responding. [/quote]


#12

Ok now I leave the firmware etc as it is, only disconnect the display

Press start at my hello world
and it gets stuck at

[quote]
Looking for a device on transport 'USB’
Starting device deployment…
Iteration 0
Opening port \?\usb#vid_1b9f&pid_0102#5&b67c184&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
Attaching debugger engine…
… debugger engine attached!
Querying device assemblies…
Found Assembly mscorlib 4.2.0.0
Found Assembly Microsoft.SPOT.Native 4.2.0.0
Found Assembly Microsoft.SPOT.Hardware 4.2.0.0
Found Assembly Microsoft.SPOT.Hardware.PWM 4.2.0.1
Found Assembly Microsoft.SPOT.Security.PKCS11 4.2.0.0
Found Assembly System.Security 4.2.0.0
Found Assembly TestG120_2 1.0.0.0
Found Assembly GHI.Premium.System 4.2.11.1
Found Assembly GHI.Premium.Hardware 4.2.11.1
Adding pe file C:\Users\jp_miata\Projects\TestG120_2\TestG120_2\bin\Debug\le\TestG120_2.pe to deployment bundle
Adding pe file C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\ghi.premium.system.pe to deployment bundle
Adding pe file C:\Program Files (x86)\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\ghi.premium.hardware.pe to deployment bundle
Attempting deployment…
Incrementally deploying assemblies to device
All assemblies on the device are up to date. No assembly deployment was necessary.
Assemblies successfully deployed to device.
Restarting interpreter…
Attaching to device…
Waiting for device to initialize…[/quote]

after a while it terminates with

[quote]The debugging target and the debugger engine failed to initialize because of unspecified device errors.
The debugger engine thread has terminated unexpectedly with error ‘Could not reconnect to the debugging target after rebooting it.’.[/quote]

and now its gone from the device manager in windows. Its not marked as faulty, its gone no device


#13

I tried it with a fresh installed Windows 7 with all updates, fresh VS2012 + framework + sdk

And I see the same behavior as befor.

So @ GHI I think its a hardware failure, because nobody else writes that he has problems, is there a way to get a new one?


#14

How did you receive a buffer overflow without a serial port being open?

The program you are loading, what does it do exactly? And what firmware version are you using?

I am not convinced it is a LCD failure as the errors you are seeing are not related.

You can send to us to test fro you but if it turned out the Hardware is not faulty you will end up paying shipping both ways so let’s try some more first.


#15

@ Gus

buffer overflow or ASSERT stands on the LCD.

I use the lastest SDK whats published yesterday.

I used two programs till now:

Hello world:


using Microsoft.SPOT;
using System.Threading;
namespace TestG120_2
{
    public class Program
    {
        public static void Main()
        {
            Debug.Print("Hallo world");
            Thread.Sleep(Timeout.Infinite);
        }
    }
}

Onewire test program:

Program.cs


using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHI.Hardware.G120;
using System.Collections;
using System.Threading;

namespace TestOnewire
{
    public class Program
    {
        public static void Main()
        {
            OutputPort port = new OutputPort(Pin.P0_13, true);
            OneWire bus = new OneWire(port);

            string text;
            float tempdata;

            ArrayList sensors = null;

            while (true)
            {
                sensors = bus.FindAllDevices();

                if (sensors.Count == 0)
                {
                    Microsoft.SPOT.Debug.Print("No sensors found");
                    Thread.Sleep(1000);
                }
                else
                {
                    bus.AcquireEx();
                    Debug.Print("Anzahl: " + sensors.Count);
                    DS1820 sensor;

                    foreach (byte[] id in sensors)
                    {
                        sensor = new DS1820(id, bus, DS1820.Mode.Single);

                        tempdata = sensor.GetValue(true);

                        text = "Sensors id: " + DS1820.ConvertToLong(id);

                        if (!sensor.IsCorrect)
                        {
                            text += "; CRC scratchpad false";
                        }
                        else
                        {
                            text += "; Temp: " + tempdata.ToString("F4") + " °C";
                        }

                        if (CRC8.Compute(id, 0, 7) != id[7])
                        {
                            text += "; CRC Rom false";
                        }

                        Microsoft.SPOT.Debug.Print(text);
                    }
                    bus.Release();
                }
            }
        }

    }
}

DS1820.cs


namespace TestOnewire
{
    using System.Threading;
    using Microsoft.SPOT.Hardware;

    public sealed class DS1820
    {
        public const byte SKIP_ROM = 0xCC;
        public const byte CONVERT = 0x44;
        public const byte MATCH_ROM = 0x55;
        public const byte READ_SCRATCHPAD = 0xBE;

        private readonly byte[] id;
        private readonly OneWire oneWireBus;
        private readonly Mode mode;
        private readonly Precision precision;

        private static object tempLock = new object();

        private byte[] scratchPad = new byte[9];
        private float value = 0.0F;
        private short temp_value;

        private bool isCorrect;

        public DS1820(byte[] sensorId, OneWire bus, Mode mode, Precision precision)
        {
            this.id = sensorId;
            this.oneWireBus = bus;
            this.mode = mode;
            this.precision = precision;
        }

        public DS1820(byte[] sensorId, OneWire bus, Mode mode)
        {
            this.id = sensorId;
            this.oneWireBus = bus;
            this.mode = mode;
            this.precision = Precision.Accurate;
        }

        public enum Mode
        {
            Single,
            Multi
        }

        public enum Precision
        {
            Simple,
            Accurate
        }

        public byte[] Id
        {
            get { return this.id; }
        }

        public bool IsCorrect
        {
            get { return this.isCorrect; }
        }

        public static ulong ConvertToLong(byte[] input)
        {
            return (ulong)input[0] | (ulong)input[1] << 8 | (ulong)input[2] << 16 | (ulong)input[3] << 24 | (ulong)input[4] << 32 | (ulong)input[5] << 40 | (ulong)input[6] << 48 | (ulong)input[7] << 56;
        }

        public float GetValue()
        {
            return this.GetValue(false);
        }

        public float GetValue(bool refresh)
        {
            if (refresh)
            {
                lock (tempLock)
                {
                    if (this.mode == Mode.Single)
                    {
                        this.RefreshTemperatureData();
                    }
                    else
                    {
                        this.ReadScratchpad();
                    }
                }
            }

            lock (this)
            {
                return this.value;
            }
        }

        public ulong GetId()
        {
            return ConvertToLong(this.id);
        }

        private void RefreshTemperatureData()
        {
            if (this.SelectSensor())
            {
                this.StartAdcConversion();

                this.ReadScratchpad();
            }
        }

        private void ReadScratchpad()
        {
            if (this.SelectSensor())
            {
                this.ReadSensorData();

                this.isCorrect = this.CheckCRC();

                if (this.isCorrect)
                {
                    this.CalculateTemperature();
                }
            }
        }

        private bool SelectSensor()
        {
            if (this.oneWireBus.TouchReset() != 0)
            {
                this.oneWireBus.WriteByte(MATCH_ROM);

                this.oneWireBus.WriteByte(this.id[0]);
                this.oneWireBus.WriteByte(this.id[1]);
                this.oneWireBus.WriteByte(this.id[2]);
                this.oneWireBus.WriteByte(this.id[3]);
                this.oneWireBus.WriteByte(this.id[4]);
                this.oneWireBus.WriteByte(this.id[5]);
                this.oneWireBus.WriteByte(this.id[6]);
                this.oneWireBus.WriteByte(this.id[7]);

                return true;
            }

            return false;
        }

        private void ReadSensorData()
        {
            this.oneWireBus.WriteByte(READ_SCRATCHPAD);

            this.scratchPad[0] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[1] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[2] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[3] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[4] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[5] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[6] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[7] = (byte)this.oneWireBus.ReadByte();
            this.scratchPad[8] = (byte)this.oneWireBus.ReadByte();
        }

        private void StartAdcConversion()
        {
            this.oneWireBus.WriteByte(CONVERT);

            while (this.oneWireBus.ReadByte() == 0)
            {
            }
        }

        private void CalculateTemperature()
        {
            temp_value = (short)((this.scratchPad[1] << 8) | this.scratchPad[0]);

            lock (this)
            {
                if (this.precision == Precision.Accurate)
                {
                    this.value = (float)((temp_value >> 1) - 0.25 + (16.0F - this.scratchPad[6]) / 16.0F);
                }
                else
                {
                    this.value = temp_value / 2.0F;
                }
            }
        }

        /// <summary>
        /// Checks if the CRC is correct
        /// </summary>
        /// <returns>true if the CRC is correct, otherwise false</returns>
        /// <remarks>not implemented yet</remarks>
        private bool CheckCRC()
        {
            return CRC8.Compute(this.scratchPad, 0, 8) == this.scratchPad[8];
        }
    }
}

CRC8.cs


/*---------------------------------------------------------------------------
* Copyright (C) 1999,2000 Maxim Integrated Products, All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated Products
* shall not be used except as stated in the Maxim Integrated Products
* Branding Policy.
*---------------------------------------------------------------------------
*/
namespace TestOnewire
{
    using System;
    /// <summary>
    /// CRC8 is a class to contain an implementation of the
    /// Cyclic-Redundency-Check CRC8 for the iButton.  The CRC8 is used
    /// in the 1-Wire Network address of all iButtons and 1-Wire devices.
    /// CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.
    /// </summary>
    public class CRC8
    {

        //--------
        //-------- Variables
        //--------


        /// <summary>
        /// CRC 8 lookup table
        /// </summary>
        private static byte[] dscrc_table;

        //--------
        //-------- Constructor
        //--------

        /// <summary> Private constructor to prevent instantiation.</summary>
        private CRC8()
        {
        }

        //--------
        //-------- Methods
        //--------

        /// <summary>
        /// Perform the CRC8 on the data element based on the provided seed.
        /// CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.
        /// </summary>
        /// <param name="dataToCrc">data element on which to perform the CRC8</param>
        /// <param name="seed">seed the CRC8 with this value</param>
        /// <returns>CRC8 value</returns>
        public static uint Compute(uint dataToCRC, uint seed)
        {
            return (uint)(dscrc_table[(seed ^ dataToCRC) & 0x0FF] & 0x0FF);
        }

        /// <summary>
        /// Perform the CRC8 on the data element based on a zero seed.
        /// CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.
        /// </summary>
        /// <param name="dataToCrc">data element on which to perform the CRC8</param>
        /// <returns>CRC8 value</returns>
        public static uint Compute(uint dataToCRC)
        {
            return (uint)(dscrc_table[dataToCRC & 0x0FF] & 0x0FF);
        }

        /// <summary>
        /// Perform the CRC8 on an array of data elements based on a zero seed.
        /// CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.
        /// </summary>
        /// <param name="dataToCrc">array of data elements on which to perform the CRC8</param>
        /// <returns>CRC8 value</returns>
        public static uint Compute(byte[] dataToCrc)
        {
            return (uint)Compute(dataToCrc, 0, dataToCrc.Length);
        }

        /// <summary>
        /// Perform the CRC8 on an array of data elements based on a zero seed.
        /// CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.
        /// </summary>
        /// <param name="dataToCrc">array of data elements on which to perform the CRC8</param>
        /// <param name="off">offset into array</param>
        /// <param name="len">length of data to crc</param>
        /// <returns>CRC8 value</returns>
        public static uint Compute(byte[] dataToCrc, int off, int len)
        {
            return (uint)Compute(dataToCrc, off, len, 0);
        }

        /// <summary>
        /// Perform the CRC8 on an array of data elements based on the provided seed.
        /// CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.
        /// </summary>
        /// <param name="dataToCrc">array of data elements on which to perform the CRC8</param>
        /// <param name="off">offset into array</param>
        /// <param name="len">length of data to crc</param>
        /// <param name="seed">seed to use for CRC8</param>
        /// <returns>CRC8 value</returns>
        public static uint Compute(byte[] dataToCrc, int off, int len, uint seed)
        {
            // loop to do the crc on each data element
            uint CRC8 = seed;

            for (int i = 0; i < len; i++)
                CRC8 = dscrc_table[(CRC8 ^ dataToCrc[i + off]) & 0x0FF];

            return (CRC8 & 0x0FF);
        }

        /// <summary>
        /// Perform the CRC8 on an array of data elements based on the provided seed.
        /// CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.
        /// </summary>
        /// <param name="dataToCrc">array of data elements on which to perform the CRC8</param>
        /// <param name="seed">seed to use for CRC8</param>
        /// <returns>CRC8 value</returns>
        public static uint Compute(byte[] dataToCrc, uint seed)
        {
            return Compute(dataToCrc, 0, dataToCrc.Length, seed);
        }

        /// <summary>
        /// Initializes the <see cref="CRC8"/> class.
        /// </summary>
        static CRC8()
        {
            /*
            * Create the lookup table
            */

            //Translated from the assembly code in iButton Standards, page 129.
            dscrc_table = new byte[256];

            int acc;
            int crc;

            for (int i = 0; i < 256; i++)
            {
                acc = i;
                crc = 0;

                for (int j = 0; j < 8; j++)
                {
                    if (((acc ^ crc) & 0x01) == 0x01)
                    {
                        crc = ((crc ^ 0x18) >> 1) | 0x80;
                    }
                    else
                        crc = crc >> 1;

                    acc = acc >> 1;
                }

                dscrc_table[i] = (byte)crc;
            }
        }

    }
}

I think it isnt the CP7, its more the cobra II board. When I look at the G120 module it isn’t perfect alignt 1-2 mm offset on the long side.

I configure the CP7 display threw fezconfig. Then I’am able to programm once and then sometimes it works then I get ASSERT or Bufferoverflow or it steps in the code but says Out of memory. very strange

So what can I check? with detailed description what to do.


#16

So I wrote an email to ghi hopefully someone is answering


#17

Running the code above gives you buffer overflow? !


#18

As I wrote, its not every time the same failure, I use the code above, and somtimes programming works, then comes a system out of memory error in the debugger, somtimes I get ASSERT on the display, sometimes I get a buffer overflow on the display, sometimes it works, sometimes nothing happens debugger is unable to attach the cobra is resetting unexpectatly … and so on.

I have tested the display with my G120HDR and it works there without any problems. It was a short test because its in a productive machine but it worked.

For me the easiest way would be to get a second Cobra II Net and test if the behavior is diffrent from mine. But I need one quick.

Any solutions?


#19

I just letting you that none of what you described sounds like a hardware faliure.


#20

Ok and what do you think, whats the problem? Even I can’t track it even when I do 10 times the same thing, I get 10 diffrent results.