Beispiel #1
0
        public override void Restart()
        {
            if (IsConnected)
            {
                cb_log?.Invoke("Restart SoC ...");

                JLinkARM.JLINKARM_Reset();
                JLinkARM.JLINKARM_Go();

                IsInited = false;
            }
        }
Beispiel #2
0
        public override bool OpenDebugger()
        {
            bool status = false;

            if (cb_log == null & CallbackLog != null)
            {
                cb_log = new CallbackLogDelegate(CallbackLog);
            }
            if (cb_err == null & CallbackError != null)
            {
                cb_err = new CallbackLogDelegate(CallbackError);
            }

            cb_log?.Invoke("Open Debugger ...");
            try
            {
                string err = JLinkARM.JLINKARM_OpenEx(cb_log, cb_err);

                if (err != null)
                {
                    status = false;
                    cb_err?.Invoke("JLINKARM_OpenEx Error!");
                    return(status);
                }
                //JLinkARM.JLINKARM_SetSpeed(TIFSpeed);
                JLinkARM.JLINKARM_SetSpeed(1000);
                JLinkARM.JLINKARM_TIF_Select(TIFType);
                JLinkARM.JLINKARM_SelectDeviceFamily(JLink_Device_Family.Cortex_M3);
                //JLinkARM.JLINKARM_SetResetType(JLink_Reset_Type.Reset_Pin);
                //JLinkARM.JLINKARM_ExecCommand("endian little", IntPtr.Zero, 0);
                //JLinkARM.JLINKARM_SetResetDelay(2);
                JLinkARM.JLINKARM_Reset();

                status = true;
            }
            catch (Exception ex)
            {
                cb_err?.Invoke(ex.Message);
            }

            IsOpen = status;
            return(status);
        }
Beispiel #3
0
        public override void Restart()
        {
            if (IsConnected)
            {
                cb_log?.Invoke("Restart SoC ...");

                JLinkARM.JLINKARM_Reset();
                if (FlashID == 0x141520C2)
                {
                    WriteU32(0x40000210, AmebaA_Code.Reg210B[(byte)RestartType]);
                }
                else
                {
                    WriteU32(0x40000210, AmebaA_Code.Reg210A[(byte)RestartType]);
                }
                JLinkARM.JLINKARM_Go();

                IsInited = false;
            }
        }
Beispiel #4
0
        public override bool InitTargert()
        {
            bool   status = false;
            UInt32 data   = 0;

            FlashID = 0x0;
            //JedecID = 0x0;

            cb_log?.Invoke("Init SoC ...");

            JLinkARM.JLINKARM_Reset();
            //JLinkARM.JLINKARM_ResetNoHalt();

            // TEST
            //UInt32[] test = new UInt32[200];
            //WriteU32((UInt32)AmebaA_Flasher.RAMAddr, 4, new UInt32[] { 0x11aa22bb , 0x33cc44dd , 0x66778899, 0x11223344 });
            //WriteU32((UInt32)AmebaA_Flasher.RAMAddr, 0x11002200);
            //ReadU32((UInt32)AmebaA_Flasher.RAMAddr, ref data);
            //ReadU32((UInt32)AmebaA_Flasher.RAMAddr, 200, ref test);

            if (IsConnected)
            {
                // System Init
                WriteU32(0x40000304, 0x1FC00002);
                WriteU32(0x40000250, 0x400);
                WriteU32(0x40000340, 0x0);
                WriteU32(0x40000230, 0xdcc4);
                WriteU32(0x40000210, 0x11113);
                WriteU32(0x400002c0, 0x110011);
                WriteU32(0x40000320, 0xffffffff);

                WriteU32(0x40000014, 0x011); // Set CLK 166.66 MHz

                status = ReadU32(0x40000230, ref data);

                if (status)
                {
                    // enable spi flash peripheral clock
                    data |= 0x300;
                    WriteU32(0x40000230, data);

                    // enable spi flash peripheral
                    ReadU32(0x40000210, ref data);
                    data &= 0x0FFFFFF;
                    data |= 0x10;
                    WriteU32(0x40000210, data);

                    // select spi flash pinout (0 - internal), enable spi flash pins
                    ReadU32(0x400002C0, ref data);
                    data &= 0xFFFFFFF8; // 0xFFFFFFF9
                    data |= 0x1;
                    WriteU32(0x400002C0, data);

                    WriteU32(0x40006008, 0x0); // disable SPI FLASH operation
                    WriteU32(0x4000602C, 0x0); // disable all interrupts
                    WriteU32(0x40006010, 0x1); // use first "slave select" pin
                    WriteU32(0x40006014, 0x2); // baud rate, default value
                    WriteU32(0x40006018, 0x0); // tx fifo threshold
                    WriteU32(0x4000601C, 0x0); // rx fifo threshold
                    WriteU32(0x4000604C, 0x0); // disable DMA

                    WriteU32(AmebaA_Addresses.Addr + 0x08, 0);
                    WriteU32(AmebaA_Addresses.Addr + 0x00, 1);
                    WriteU32(AmebaA_Addresses.FirmwareAddr, (UInt32)AmebaA_Code.Flasher.Length, AmebaA_Code.Flasher);
                    // Если нажали сброс в пустую RAM, то запустит RTLConcoleRAM
                    WriteU32(AmebaA_Addresses.RAMBootAddr, (UInt32)AmebaA_Code.Console.Length, AmebaA_Code.Console);

                    JLinkARM.JLINKARM_WriteReg((UInt32)JLink_ARM_CM3_Register.FAULTMASK, 0x00);                            //0x01
                    JLinkARM.JLINKARM_WriteReg((UInt32)JLink_ARM_CM3_Register.R13, (UInt32)AmebaA_Addresses.Stack);        // $sp
                    JLinkARM.JLINKARM_WriteReg((UInt32)JLink_ARM_CM3_Register.R15, (UInt32)AmebaA_Addresses.FirmwareAddr); // $pc
                    JLinkARM.JLINKARM_Go();
                    //cb_log?.Invoke(String.Format("Is halted ? {0}", JLinkARM.JLINKARM_IsHalted()));
                    status = false;

                    if (WaitTarget())
                    {
                        ReadFlashID();
                        //ReadU32(AmebaA_Flasher.Addr + 0x0C, ref data);
                        //FlashID = (UInt32)((data & 0xFFFFFF) | (FlashWriteReadCMD(0xAB, 3, 1) << 24));
                        CheckFlashID();
                        status = true;
                    }
                }
            }

            IsInited = status;
            return(status);
        }