Ejemplo n.º 1
0
        public override bool InitTargert()
        {
            bool   status = false;
            UInt32 data   = 0;

            FlashID = 0x0;

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

            //JLinkARM.JLINKARM_Reset();
            JLinkARM.JLINKARM_Halt();
            ReadFlashID();

            // RAM test

            /*
             * UInt32[] test = new UInt32[200];
             * for (UInt16 i = 0; i < test.Length; i++)
             *  test[i] = i;
             * WriteU32((UInt32)AmebaZ_Addresses.RAMAddr, (UInt32)test.Length, test);
             * WriteU32((UInt32)AmebaZ_Addresses.RAMAddr, 0x11002200);
             *
             * UInt32[] test_r = new UInt32[200];
             * ReadU32((UInt32)AmebaZ_Addresses.RAMAddr, 200, ref test_r);
             */

            if (IsConnected)
            {
                // System Init
                ReadU32(0x40000210, ref data);
                data &= 0xe7ff_ffff; // 27, 28
                data |= 0x0400_0000; // 26
                WriteU32(0x40000210, data);

                // Load Flasher
                WriteU32(AmebaZ_Addresses.RAMImage1Addr, (UInt32)AmebaZ_Code.Flasher.Length, AmebaZ_Code.Flasher);

                JLinkARM.JLINKARM_WriteReg((UInt32)JLink_ARM_CM4_Register.FAULTMASK, 0x00);
                JLinkARM.JLINKARM_WriteReg((UInt32)JLink_ARM_CM4_Register.R13, (UInt32)AmebaZ_Addresses.Stack);        // Stack pointer
                JLinkARM.JLINKARM_WriteReg((UInt32)JLink_ARM_CM4_Register.R15, (UInt32)AmebaZ_Addresses.FirmwareAddr); // Program counter
                JLinkARM.JLINKARM_Go();
                status = true;
            }

            IsInited = status;
            return(status);
        }