⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flash.cod

📁 一个berry eboot 源代码
💻 COD
📖 第 1 页 / 共 5 页
字号:
  00054	eb000000	 bl          EdbgOutputDebugString

; 593  :             return(FALSE);

  00058	e3a00000	 mov         r0, #0
  0005c	ea00007e	 b           |$L40145|
  00060		 |$L40167|

; 486  :         return(FALSE);
; 487  :     }
; 488  : 
; 489  :     if (!FlashErase(FlashStart, DataLength))

  00060	e59d0000	 ldr         r0, [sp]
  00064	e1a01004	 mov         r1, r4
  00068	eb000000	 bl          FlashErase
  0006c	e3500000	 cmp         r0, #0

; 490  :     {
; 491  :         return(FALSE);

  00070	0a000086	 beq         |$L40458|

; 492  :     }
; 493  :         
; 494  :     b = 0;
; 495  : 
; 496  :     if (g_FlashDeviceType == J3)

  00074	e5963000	 ldr         r3, [r6]
  00078	e3a01000	 mov         r1, #0
  0007c	e58d100c	 str         r1, [sp, #0xC]
  00080	e3530005	 cmp         r3, #5

; 497  :     {
; 498  :         sizeFlashCache = 64;   // 64 bytes total, 32 bytes per device

  00084	03a05040	 moveq       r5, #0x40

; 499  :         chunksPerBlock = 4096; // 256K / 64bytes = 4096

  00088	03a08a01	 moveq       r8, #1, 20
  0008c	0a00000c	 beq         |$L40172|

; 500  :     }
; 501  :     else if ((g_FlashDeviceType == K3) || (g_FlashDeviceType == K18) || (g_FlashDeviceType == L18) || (g_FlashDeviceType == L30))

  00090	e3530003	 cmp         r3, #3
  00094	0a000005	 beq         |$L40173|
  00098	e3530004	 cmp         r3, #4
  0009c	0a000003	 beq         |$L40173|
  000a0	e3530001	 cmp         r3, #1
  000a4	0a000001	 beq         |$L40173|
  000a8	e3530002	 cmp         r3, #2
  000ac	1a000002	 bne         |$L40434|
  000b0		 |$L40173|

; 502  :     {
; 503  :         sizeFlashCache = 128;  // 128 bytes total, 64 bytes per device

  000b0	e3a05080	 mov         r5, #0x80

; 504  :         chunksPerBlock = 2048; // 256K / 128bytes = 2048

  000b4	e3a08b02	 mov         r8, #2, 22
  000b8	ea000001	 b           |$L40172|
  000bc		 |$L40434|
  000bc	e59d5018	 ldr         r5, [sp, #0x18]
  000c0	e59d8018	 ldr         r8, [sp, #0x18]
  000c4		 |$L40172|

; 505  :     }
; 506  : 
; 507  :     EdbgOutputDebugString("INFO: FlashWrite: writing to flash...\r\n");

  000c4	e59f01e4	 ldr         r0, [pc, #0x1E4]
  000c8	eb000000	 bl          EdbgOutputDebugString

; 508  : 
; 509  :     while (DataLength > 0)

  000cc	e3a098ff	 mov         r9, #0xFF, 16
  000d0	e38990ff	 orr         r9, r9, #0xFF
  000d4	e3540000	 cmp         r4, #0
  000d8	0a00004d	 beq         |$L40177|
  000dc	e5962000	 ldr         r2, [r6]
  000e0	e3a0173a	 mov         r1, #0x3A, 14
  000e4	e3a0a502	 mov         r10, #2, 10
  000e8	e58d2004	 str         r2, [sp, #4]
  000ec	e38110e8	 orr         r1, r1, #0xE8
  000f0	e38aa080	 orr         r10, r10, #0x80
  000f4		 |$L40176|

; 510  :     {
; 511  :         // Calculate the number of DWORDS to program in each iteration based on the size in bytes
; 512  :         // of the flash cache.
; 513  :         if (DataLength > sizeFlashCache)

  000f4	e1540005	 cmp         r4, r5

; 514  :             count = sizeFlashCache / 4;

  000f8	81a0e125	 movhi       lr, r5, lsr #2

; 515  :         else
; 516  :             count = DataLength / 4;

  000fc	91a0e124	 movls       lr, r4, lsr #2
  00100		 |$L40181|

; 517  : 
; 518  :         // Issue Write to Buffer Command
; 519  :         *pBlockAddress = 0x00E800E8;
; 520  : 
; 521  :         // Check that the write buffer is available.
; 522  :         // Read the Extended Status Register and
; 523  :         // wait for the assertion of XSR[7] before continuing.
; 524  :         while ( (*pBlockAddress & 0x00800080) != 0x00800080)
; 525  :         {
; 526  :             *pBlockAddress = 0x00E800E8;

  00100	e58b1000	 str         r1, [r11]
  00104	e59b3000	 ldr         r3, [r11]
  00108	e003300a	 and         r3, r3, r10
  0010c	e153000a	 cmp         r3, r10
  00110	1afffffa	 bne         |$L40181|

; 527  :         }
; 528  : 
; 529  :         // Configure the size of the buffer that we will write.
; 530  :         // Write the word count (device expects a 0 based number)
; 531  :         *pBlockAddress = ((count - 1) << 16 | (count - 1));
; 532  : 
; 533  :         pdwFlashStart = pDeviceAddress;

  00114	e59d1010	 ldr         r1, [sp, #0x10]
  00118	e24e3001	 sub         r3, lr, #1
  0011c	e1833803	 orr         r3, r3, r3, lsl #16

; 534  :         pdwRamStart   = pFlashCache;

  00120	e59d6008	 ldr         r6, [sp, #8]
  00124	e58b3000	 str         r3, [r11]
  00128	e1a00001	 mov         r0, r1

; 535  : 
; 536  :         // Write up to "count" DWORDS into the Flash memory staging area
; 537  :         for (i = 0; i < count; i++)

  0012c	e35e0000	 cmp         lr, #0
  00130	0a00000a	 beq         |$L40185|
  00134	e1a0200e	 mov         r2, lr

; 538  :         {
; 539  :             *pDeviceAddress++ = *pFlashCache++;

  00138	e1a09006	 mov         r9, r6
  0013c		 |$L40183|
  0013c	e4993004	 ldr         r3, [r9], #4
  00140	e2522001	 subs        r2, r2, #1
  00144	e4813004	 str         r3, [r1], #4
  00148	1afffffb	 bne         |$L40183|
  0014c	e58d9008	 str         r9, [sp, #8]
  00150	e3a098ff	 mov         r9, #0xFF, 16

; 563  :             }
; 564  : 
; 565  :             if (*pdwFlashStart++ != *pdwRamStart++)

  00154	e59d2004	 ldr         r2, [sp, #4]
  00158	e38990ff	 orr         r9, r9, #0xFF
  0015c	e58d1010	 str         r1, [sp, #0x10]
  00160		 |$L40185|
  00160	e59d300c	 ldr         r3, [sp, #0xC]
  00164	e2833001	 add         r3, r3, #1
  00168	e58d300c	 str         r3, [sp, #0xC]
  0016c	e3a0360d	 mov         r3, #0xD, 12
  00170	e38330d0	 orr         r3, r3, #0xD0
  00174	e58b3000	 str         r3, [r11]
  00178		 |$L40187|
  00178	e59b3000	 ldr         r3, [r11]
  0017c	e003300a	 and         r3, r3, r10
  00180	e153000a	 cmp         r3, r10
  00184	1afffffb	 bne         |$L40187|
  00188	e59d3014	 ldr         r3, [sp, #0x14]
  0018c	e044410e	 sub         r4, r4, lr, lsl #2
  00190	e3a01000	 mov         r1, #0
  00194	e5839000	 str         r9, [r3]
  00198	e35e0000	 cmp         lr, #0
  0019c	0a00000c	 beq         |$L40191|
  001a0		 |$L40189|

; 540  :         }
; 541  : 
; 542  :         // increment the number of 64 or 128 byte segments written.
; 543  :         b++;
; 544  : 
; 545  :         // Now program the buffer into Flash
; 546  :         *pBlockAddress = 0x00D000D0;
; 547  : 
; 548  :         i = 0;
; 549  :         while ((i & 0x00800080) != 0x00800080)
; 550  :         {
; 551  :             i = *pBlockAddress;
; 552  :         }
; 553  : 
; 554  :         DataLength -= count << 2;
; 555  : 
; 556  :         // Read back the segment just written
; 557  :         *pFlash = 0x00FF00FF;
; 558  :         for (i = 0; i < count; i++)
; 559  :         {
; 560  :             if ((g_FlashDeviceType == L18) || (g_FlashDeviceType == L30))

  001a0	e3520001	 cmp         r2, #1
  001a4	0a000001	 beq         |$L40193|
  001a8	e3520002	 cmp         r2, #2
  001ac	1a000000	 bne         |$L40192|
  001b0		 |$L40193|

; 561  :             {
; 562  :                 *pdwFlashStart = 0x00FF00FF;

  001b0	e5809000	 str         r9, [r0]
  001b4		 |$L40192|

; 563  :             }
; 564  : 
; 565  :             if (*pdwFlashStart++ != *pdwRamStart++)

  001b4	e4902004	 ldr         r2, [r0], #4
  001b8	e4963004	 ldr         r3, [r6], #4
  001bc	e1520003	 cmp         r2, r3
  001c0	1a000028	 bne         |$L40426|
  001c4	e2811001	 add         r1, r1, #1
  001c8	e59d2004	 ldr         r2, [sp, #4]
  001cc	e151000e	 cmp         r1, lr
  001d0	3afffff2	 bcc         |$L40189|
  001d4		 |$L40191|

; 569  :             }
; 570  :         }
; 571  : 
; 572  :         if ((b % chunksPerBlock) == 0)

  001d4	e59d100c	 ldr         r1, [sp, #0xC]
  001d8	e1a00008	 mov         r0, r8
  001dc	eb000000	 bl          __rt_udiv
  001e0	e3510000	 cmp         r1, #0
  001e4	1a000005	 bne         |$L40455|

; 573  :         {
; 574  :             EdbgOutputDebugString(".");

  001e8	e59f00bc	 ldr         r0, [pc, #0xBC]
  001ec	eb000000	 bl          EdbgOutputDebugString
  001f0	e59f30b0	 ldr         r3, [pc, #0xB0]
  001f4	e5932000	 ldr         r2, [r3]
  001f8	e58d2004	 str         r2, [sp, #4]
  001fc	ea000000	 b           |$L40196|
  00200		 |$L40455|
  00200	e59d2004	 ldr         r2, [sp, #4]
  00204		 |$L40196|
  00204	e3a0173a	 mov         r1, #0x3A, 14
  00208	e38110e8	 orr         r1, r1, #0xE8
  0020c	e3540000	 cmp         r4, #0
  00210	1affffb7	 bne         |$L40176|
  00214		 |$L40177|

; 575  :         }
; 576  :     }
; 577  : 
; 578  :     // Verify the data written to flash...
; 579  :     //
; 580  :     pFlash      = (volatile UINT32 *) FlashStart;

  00214	e59d4000	 ldr         r4, [sp]

; 581  :     pFlashCache = (UINT32 *) pDataBuffer;
; 582  : 
; 583  :     // Put Flash into read mode.
; 584  :     *pFlash = 0x00FF00FF;
; 585  : 
; 586  :     EdbgOutputDebugString("INFO: FlashWrite: verifying the data written to flash...\r\n");

  00218	e59f0084	 ldr         r0, [pc, #0x84]
  0021c	e5849000	 str         r9, [r4]
  00220	eb000000	 bl          EdbgOutputDebugString

; 587  : 
; 588  :     for ( j = 0; j < dwLength/4; j++ )

  00224	e59d3018	 ldr         r3, [sp, #0x18]
  00228	e3a01000	 mov         r1, #0
  0022c	e1b00123	 movs        r0, r3, lsr #2
  00230	0a000006	 beq         |$L40202|
  00234		 |$L40200|

; 589  :     {
; 590  :         if (*pFlash++ != *pFlashCache++)

  00234	e4942004	 ldr         r2, [r4], #4
  00238	e4973004	 ldr         r3, [r7], #4
  0023c	e1520003	 cmp         r2, r3
  00240	1a00000c	 bne         |$L40427|
  00244	e2811001	 add         r1, r1, #1
  00248	e1510000	 cmp         r1, r0
  0024c	3afffff8	 bcc         |$L40200|
  00250		 |$L40202|

; 594  :         }
; 595  :     }
; 596  : 
; 597  :     EdbgOutputDebugString("INFO: FlashWrite: flash programmed successfully!\r\n");

  00250	e59f0048	 ldr         r0, [pc, #0x48]
  00254	eb000000	 bl          EdbgOutputDebugString

; 598  : 
; 599  :     return(TRUE);

  00258	e3a00001	 mov         r0, #1
  0025c		 |$L40145|

; 600  : }

  0025c	e28dd01c	 add         sp, sp, #0x1C
  00260	e8bd4ff0	 ldmia       sp!, {r4 - r11, lr}
  00264	e12fff1e	 bx          lr
  00268		 |$L40426|

; 566  :             {
; 567  :                 EdbgOutputDebugString("ERROR: FlashWrite: flash programming failure at address 0x%x (expected 0x%x actual 0x%x).\r\n", pdwFlashStart-1, *(pdwRamStart-1), *(pdwFlashStart-1));

  00268	e2401004	 sub         r1, r0, #4
  0026c	e59f0028	 ldr         r0, [pc, #0x28]
  00270	e2462004	 sub         r2, r6, #4

; 568  :                 return(FALSE);

  00274	ea000002	 b           |$L40459|
  00278		 |$L40427|

; 591  :         {
; 592  :             EdbgOutputDebugString( "ERROR: FlashWrite: verification failure at address 0x%x (expected 0x%x actual 0x%x))\r\n", pFlash-1, *(pFlashCache-1), *(pFlash-1) );

  00278	e59f0018	 ldr         r0, [pc, #0x18]
  0027c	e2441004	 sub         r1, r4, #4
  00280	e2472004	 sub         r2, r7, #4
  00284		 |$L40459|
  00284	e5913000	 ldr         r3, [r1]
  00288	e5922000	 ldr         r2, [r2]
  0028c	eb000000	 bl          EdbgOutputDebugString
  00290		 |$L40458|

; 593  :             return(FALSE);

  00290	e3a00000	 mov         r0, #0
  00294	eafffff0	 b           |$L40145|
  00298		 |$L40465|
  00298	00000000	 DCD         |??_C@_0FH@HBFAGKLL@ERROR?3?5FlashWrite?3?5verification?5@|
  0029c	00000000	 DCD         |??_C@_0FM@EPPFHNCB@ERROR?3?5FlashWrite?3?5flash?5program@|
  002a0	00000000	 DCD         |??_C@_0DD@IDDBKFOE@INFO?3?5FlashWrite?3?5flash?5programm@|
  002a4	00000000	 DCD         |??_C@_0DL@HPDDOHNE@INFO?3?5FlashWrite?3?5verifying?5the?5@|
  002a8	00000000	 DCD         |g_FlashDeviceType|
  002ac	00000000	 DCD         |??_C@_01LFCBOECM@?4?$AA@|
  002b0	00000000	 DCD         |??_C@_0CI@KIPMHENK@INFO?3?5FlashWrite?3?5writing?5to?5fla@|
  002b4	00000000	 DCD         |??_C@_0CO@BHODJGNH@ERROR?3?5FlashWrite?3?5unrecognized?5@|
  002b8	00000000	 DCD         |??_C@_0DB@PKAGHONA@?$CK?$CK?$CK?$CK?$CK?$CK?$CK?$CK?$CK?$CK?5FlashStart_Addr?5?$DN?50x?$CF@|
  002bc		 |$M40461|

			 ENDP  ; |FlashWrite|

	EXPORT	|??_C@_0CO@JKHKCFAJ@INFO?3?5bootloader?5image?5stored?5su@| [ DATA ] ; `string'
	EXPORT	|??_C@_0BO@PPDGJDDI@Reboot?5the?5system?5manually?4?5?5?$AA@| [ DATA ] ; `string'
	EXPORT	|OEMWriteFlash|
	IMPORT	|g_ImageType|
	IMPORT	|SpinForever|

  00000			 AREA	 |.text| { |OEMWriteFlash| }, COD

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -