   1              		.file	"main.c"
   2              		.option nopic
   3              		.attribute arch, "rv32i2p0_m2p0"
   4              		.attribute unaligned_access, 0
   5              		.attribute stack_align, 16
   6              		.text
   7              		.section	.text.delay1,"ax",@progbits
   8              		.align	2
   9              		.globl	delay1
  11              	delay1:
  12 0000 130101FF 		addi	sp,sp,-16
  13 0004 2326A100 		sw	a0,12(sp)
  14 0008 8327C100 		lw	a5,12(sp)
  15 000c 638C0700 		beq	a5,zero,.L1
  16              	.L3:
  17 0010 8327C100 		lw	a5,12(sp)
  18 0014 9387F7FF 		addi	a5,a5,-1
  19 0018 2326F100 		sw	a5,12(sp)
  20 001c 8327C100 		lw	a5,12(sp)
  21 0020 E39807FE 		bne	a5,zero,.L3
  22              	.L1:
  23 0024 13010101 		addi	sp,sp,16
  24 0028 67800000 		jr	ra
  26              		.section	.text.number_size,"ax",@progbits
  27              		.align	2
  28              		.globl	number_size
  30              	number_size:
  31 0000 83460500 		lbu	a3,0(a0)
  32 0004 13070500 		mv	a4,a0
  33 0008 638A0602 		beq	a3,zero,.L13
  34 000c 13069500 		addi	a2,a0,9
  35 0010 13050000 		li	a0,0
  36              	.L12:
  37 0014 93172500 		slli	a5,a0,2
  38 0018 B387A700 		add	a5,a5,a0
  39 001c 13071700 		addi	a4,a4,1
  40 0020 93971700 		slli	a5,a5,1
  41 0024 B387D700 		add	a5,a5,a3
  42 0028 83460700 		lbu	a3,0(a4)
  43 002c 138507FD 		addi	a0,a5,-48
  44 0030 63880600 		beq	a3,zero,.L10
  45 0034 E310C7FE 		bne	a4,a2,.L12
  46 0038 67800000 		ret
  47              	.L13:
  48 003c 13050000 		li	a0,0
  49              	.L10:
  50 0040 67800000 		ret
  52              		.section	.text.copy_to_flash,"ax",@progbits
  53              		.align	2
  54              		.globl	copy_to_flash
  56              	copy_to_flash:
  57 0000 130101FE 		addi	sp,sp,-32
  58 0004 232A9100 		sw	s1,20(sp)
  59 0008 B7040000 		lui	s1,%hi(.LANCHOR0)
  60 000c 232C8100 		sw	s0,24(sp)
  61 0010 23282101 		sw	s2,16(sp)
  62 0014 23263101 		sw	s3,12(sp)
  63 0018 232E1100 		sw	ra,28(sp)
  64 001c 93090500 		mv	s3,a0
  65 0020 13040000 		li	s0,0
  66 0024 93840400 		addi	s1,s1,%lo(.LANCHOR0)
  67 0028 37190000 		li	s2,4096
  68              	.L19:
  69 002c 03A50400 		lw	a0,0(s1)
  70 0030 B3858900 		add	a1,s3,s0
  71 0034 13060020 		li	a2,512
  72 0038 3305A400 		add	a0,s0,a0
  73 003c 13040420 		addi	s0,s0,512
  74 0040 97000000 		call	FLASH_program
  74      E7800000 
  75 0048 E31224FF 		bne	s0,s2,.L19
  76 004c 83A70400 		lw	a5,0(s1)
  77 0050 8320C101 		lw	ra,28(sp)
  78 0054 03290101 		lw	s2,16(sp)
  79 0058 33848700 		add	s0,a5,s0
  80 005c 23A08400 		sw	s0,0(s1)
  81 0060 03248101 		lw	s0,24(sp)
  82 0064 83244101 		lw	s1,20(sp)
  83 0068 8329C100 		lw	s3,12(sp)
  84 006c 13010102 		addi	sp,sp,32
  85 0070 67800000 		jr	ra
  87              		.section	.text.load_spi_flash_with_images_thruough_uart_intf,"ax",@progbits
  88              		.align	2
  89              		.globl	load_spi_flash_with_images_thruough_uart_intf
  91              	load_spi_flash_with_images_thruough_uart_intf:
  92 0000 130101F7 		addi	sp,sp,-144
  93 0004 23240102 		sw	zero,40(sp)
  94 0008 23260102 		sw	zero,44(sp)
  95 000c 23280102 		sw	zero,48(sp)
  96 0010 23248108 		sw	s0,136(sp)
  97 0014 23261108 		sw	ra,140(sp)
  98 0018 23229108 		sw	s1,132(sp)
  99 001c 23202109 		sw	s2,128(sp)
 100 0020 232E3107 		sw	s3,124(sp)
 101 0024 232C4107 		sw	s4,120(sp)
 102 0028 232A5107 		sw	s5,116(sp)
 103 002c 23286107 		sw	s6,112(sp)
 104 0030 23267107 		sw	s7,108(sp)
 105 0034 23248107 		sw	s8,104(sp)
 106 0038 23229107 		sw	s9,100(sp)
 107 003c 2320A107 		sw	s10,96(sp)
 108 0040 232EB105 		sw	s11,92(sp)
 109 0044 232A0102 		sw	zero,52(sp)
 110 0048 37040000 		lui	s0,%hi(g_uart)
 111              	.L23:
 112 004c 13061000 		li	a2,1
 113 0050 9305C103 		addi	a1,sp,60
 114 0054 13050400 		addi	a0,s0,%lo(g_uart)
 115 0058 97000000 		call	UART_get_rx
 115      E7800000 
 116 0060 E30605FE 		beq	a0,zero,.L23
 117 0064 0347C103 		lbu	a4,60(sp)
 118 0068 93073007 		li	a5,115
 119 006c 6300F772 		beq	a4,a5,.L144
 120              	.L24:
 121 0070 97000000 		call	FLASH_init
 121      E7800000 
 122 0078 97000000 		call	FLASH_global_unprotect
 122      E7800000 
 123 0080 93053102 		addi	a1,sp,35
 124 0084 13052102 		addi	a0,sp,34
 125 0088 97000000 		call	FLASH_read_device_id
 125      E7800000 
 126 0090 23260102 		sw	zero,44(sp)
 127 0094 23240102 		sw	zero,40(sp)
 128 0098 23260102 		sw	zero,44(sp)
 129 009c 0327C102 		lw	a4,44(sp)
 130 00a0 93070001 		li	a5,16
 131 00a4 63E0E772 		bgtu	a4,a5,.L81
 132 00a8 B7040000 		lui	s1,%hi(g_read_buf)
 133 00ac B7070000 		lui	a5,%hi(g_gpio)
 134 00b0 23240100 		sw	zero,8(sp)
 135 00b4 2326F100 		sw	a5,12(sp)
 136 00b8 938A0400 		addi	s5,s1,%lo(g_read_buf)
 137 00bc 370A0100 		li	s4,65536
 138 00c0 9309F00F 		li	s3,255
 139 00c4 13090001 		li	s2,16
 140              	.L29:
 141 00c8 8327C100 		lw	a5,12(sp)
 142 00cc 03268100 		lw	a2,8(sp)
 143 00d0 93050000 		li	a1,0
 144 00d4 13850700 		addi	a0,a5,%lo(g_gpio)
 145 00d8 97000000 		call	GPIO_set_output
 145      E7800000 
 146 00e0 03258102 		lw	a0,40(sp)
 147 00e4 97000000 		call	FLASH_erase_64k_block
 147      E7800000 
 148 00ec 9307401F 		li	a5,500
 149              	.L26:
 150 00f0 9387F7FF 		addi	a5,a5,-1
 151 00f4 E39E07FE 		bne	a5,zero,.L26
 152 00f8 03258102 		lw	a0,40(sp)
 153 00fc 13060002 		li	a2,32
 154 0100 93850400 		addi	a1,s1,%lo(g_read_buf)
 155 0104 97000000 		call	FLASH_read
 155      E7800000 
 156 010c 83278102 		lw	a5,40(sp)
 157 0110 03C70A00 		lbu	a4,0(s5)
 158 0114 B3874701 		add	a5,a5,s4
 159 0118 2324F102 		sw	a5,40(sp)
 160 011c 63123703 		bne	a4,s3,.L25
 161 0120 8327C102 		lw	a5,44(sp)
 162 0124 03278100 		lw	a4,8(sp)
 163 0128 93871700 		addi	a5,a5,1
 164 012c 2326F102 		sw	a5,44(sp)
 165 0130 8327C102 		lw	a5,44(sp)
 166 0134 13471700 		xori	a4,a4,1
 167 0138 2324E100 		sw	a4,8(sp)
 168 013c E376F9F8 		bleu	a5,s2,.L29
 169              	.L25:
 170 0140 0327C102 		lw	a4,44(sp)
 171 0144 93075000 		li	a5,5
 172 0148 6304F762 		beq	a4,a5,.L145
 173 014c 8327C100 		lw	a5,12(sp)
 174 0150 13060000 		li	a2,0
 175 0154 93050000 		li	a1,0
 176 0158 13850700 		addi	a0,a5,%lo(g_gpio)
 177 015c 97000000 		call	GPIO_set_output
 177      E7800000 
 178              	.L31:
 179 0164 B7070000 		lui	a5,%hi(.LANCHOR1)
 180 0168 93870700 		addi	a5,a5,%lo(.LANCHOR1)
 181 016c 232CF100 		sw	a5,24(sp)
 182 0170 83C70700 		lbu	a5,0(a5)
 183 0174 6394073A 		bne	a5,zero,.L32
 184 0178 B7070000 		lui	a5,%hi(.LANCHOR0)
 185 017c 93870700 		addi	a5,a5,%lo(.LANCHOR0)
 186 0180 232AF100 		sw	a5,20(sp)
 187 0184 B7070000 		lui	a5,%hi(.LANCHOR2)
 188 0188 93870700 		addi	a5,a5,%lo(.LANCHOR2)
 189 018c 232EF100 		sw	a5,28(sp)
 190 0190 B7070000 		lui	a5,%hi(.LANCHOR4)
 191 0194 370B0000 		lui	s6,%hi(.LANCHOR3)
 192 0198 93870700 		addi	a5,a5,%lo(.LANCHOR4)
 193 019c B7090000 		lui	s3,%hi(g_write_buffer)
 194 01a0 B70B0000 		lui	s7,%hi(.LC0)
 195 01a4 130B0B00 		addi	s6,s6,%lo(.LANCHOR3)
 196 01a8 2328F100 		sw	a5,16(sp)
 197 01ac 93890900 		addi	s3,s3,%lo(g_write_buffer)
 198 01b0 370D0000 		lui	s10,%hi(.LC7)
 199              	.L79:
 200 01b4 8327C101 		lw	a5,28(sp)
 201 01b8 03274101 		lw	a4,20(sp)
 202 01bc 23200B00 		sw	zero,0(s6)
 203 01c0 83A70700 		lw	a5,0(a5)
 204 01c4 2320F700 		sw	a5,0(a4)
 205              	.L33:
 206 01c8 13061000 		li	a2,1
 207 01cc 9305C103 		addi	a1,sp,60
 208 01d0 13050400 		addi	a0,s0,%lo(g_uart)
 209 01d4 97000000 		call	UART_get_rx
 209      E7800000 
 210 01dc E30605FE 		beq	a0,zero,.L33
 211 01e0 0347C103 		lbu	a4,60(sp)
 212 01e4 93078006 		li	a5,104
 213 01e8 630AF754 		beq	a4,a5,.L146
 214              	.L35:
 215 01ec 13061000 		li	a2,1
 216 01f0 9305C103 		addi	a1,sp,60
 217 01f4 13050400 		addi	a0,s0,%lo(g_uart)
 218 01f8 97000000 		call	UART_get_rx
 218      E7800000 
 219 0200 E30605FE 		beq	a0,zero,.L35
 220 0204 0347C103 		lbu	a4,60(sp)
 221 0208 9307E006 		li	a5,110
 222 020c 6304F754 		beq	a4,a5,.L147
 223              	.L37:
 224 0210 13061000 		li	a2,1
 225 0214 9305C103 		addi	a1,sp,60
 226 0218 13050400 		addi	a0,s0,%lo(g_uart)
 227 021c 97000000 		call	UART_get_rx
 227      E7800000 
 228 0224 E30605FE 		beq	a0,zero,.L37
 229 0228 0347C103 		lbu	a4,60(sp)
 230 022c 93073007 		li	a5,115
 231 0230 6308F74E 		beq	a4,a5,.L148
 232              	.L39:
 233 0234 13061000 		li	a2,1
 234 0238 9305C103 		addi	a1,sp,60
 235 023c 13050400 		addi	a0,s0,%lo(g_uart)
 236 0240 97000000 		call	UART_get_rx
 236      E7800000 
 237 0248 E30605FE 		beq	a0,zero,.L39
 238 024c 0347C103 		lbu	a4,60(sp)
 239 0250 93071006 		li	a5,97
 240 0254 6308F74A 		beq	a4,a5,.L149
 241              	.L41:
 242 0258 13061000 		li	a2,1
 243 025c 9305C103 		addi	a1,sp,60
 244 0260 13050400 		addi	a0,s0,%lo(g_uart)
 245 0264 97000000 		call	UART_get_rx
 245      E7800000 
 246 026c E30605FE 		beq	a0,zero,.L41
 247 0270 0347C103 		lbu	a4,60(sp)
 248 0274 93075006 		li	a5,101
 249 0278 6308F746 		beq	a4,a5,.L150
 250              	.L43:
 251 027c 13061000 		li	a2,1
 252 0280 9305C103 		addi	a1,sp,60
 253 0284 13050400 		addi	a0,s0,%lo(g_uart)
 254 0288 97000000 		call	UART_get_rx
 254      E7800000 
 255 0290 E30605FE 		beq	a0,zero,.L43
 256 0294 13061000 		li	a2,1
 257 0298 93850B00 		addi	a1,s7,%lo(.LC0)
 258 029c 13050400 		addi	a0,s0,%lo(g_uart)
 259 02a0 97000000 		call	UART_send
 259      E7800000 
 260 02a8 B7070000 		lui	a5,%hi(.LC5)
 261 02ac 93850700 		addi	a1,a5,%lo(.LC5)
 262 02b0 13061000 		li	a2,1
 263 02b4 13050400 		addi	a0,s0,%lo(g_uart)
 264 02b8 97000000 		call	UART_send
 264      E7800000 
 265 02c0 23280102 		sw	zero,48(sp)
 266 02c4 03270103 		lw	a4,48(sp)
 267 02c8 93078000 		li	a5,8
 268 02cc 93048000 		li	s1,8
 269 02d0 63E2E704 		bgtu	a4,a5,.L48
 270              	.L47:
 271 02d4 13061000 		li	a2,1
 272 02d8 9305C103 		addi	a1,sp,60
 273 02dc 13050400 		addi	a0,s0,%lo(g_uart)
 274 02e0 97000000 		call	UART_get_rx
 274      E7800000 
 275 02e8 E30605FE 		beq	a0,zero,.L47
 276 02ec 83270103 		lw	a5,48(sp)
 277 02f0 03270103 		lw	a4,48(sp)
 278 02f4 93060105 		addi	a3,sp,80
 279 02f8 B387F600 		add	a5,a3,a5
 280 02fc 13071700 		addi	a4,a4,1
 281 0300 2328E102 		sw	a4,48(sp)
 282 0304 8346C103 		lbu	a3,60(sp)
 283 0308 03270103 		lw	a4,48(sp)
 284 030c 238AD7FE 		sb	a3,-12(a5)
 285 0310 E3F2E4FC 		bleu	a4,s1,.L47
 286              	.L48:
 287 0314 03464104 		lbu	a2,68(sp)
 288 0318 13074104 		addi	a4,sp,68
 289 031c 93060000 		li	a3,0
 290 0320 9305D104 		addi	a1,sp,77
 291 0324 63040602 		beq	a2,zero,.L46
 292              	.L45:
 293 0328 93972600 		slli	a5,a3,2
 294 032c B387D700 		add	a5,a5,a3
 295 0330 13071700 		addi	a4,a4,1
 296 0334 93971700 		slli	a5,a5,1
 297 0338 B387C700 		add	a5,a5,a2
 298 033c 03460700 		lbu	a2,0(a4)
 299 0340 938607FD 		addi	a3,a5,-48
 300 0344 63040600 		beq	a2,zero,.L46
 301 0348 E310B7FE 		bne	a4,a1,.L45
 302              	.L46:
 303 034c 83270101 		lw	a5,16(sp)
 304 0350 13061000 		li	a2,1
 305 0354 93850B00 		addi	a1,s7,%lo(.LC0)
 306 0358 13050400 		addi	a0,s0,%lo(g_uart)
 307 035c 23A0D700 		sw	a3,0(a5)
 308 0360 B70C0000 		lui	s9,%hi(.LC6)
 309 0364 97000000 		call	UART_send
 309      E7800000 
 310              	.L78:
 311 036c 83270101 		lw	a5,16(sp)
 312 0370 83260B00 		lw	a3,0(s6)
 313 0374 232C0102 		sw	zero,56(sp)
 314 0378 03A70700 		lw	a4,0(a5)
 315 037c B7170000 		li	a5,4096
 316 0380 B387F600 		add	a5,a3,a5
 317 0384 37190000 		li	s2,4096
 318 0388 6374F700 		bleu	a5,a4,.L49
 319 038c 3309D740 		sub	s2,a4,a3
 320              	.L49:
 321 0390 930D0000 		li	s11,0
 322 0394 63FCE612 		bgeu	a3,a4,.L50
 323 0398 130AF9FF 		addi	s4,s2,-1
 324 039c 930A1006 		li	s5,97
 325 03a0 9304301F 		li	s1,499
 326 03a4 130CE006 		li	s8,110
 327              	.L51:
 328 03a8 13061000 		li	a2,1
 329 03ac 93850C00 		addi	a1,s9,%lo(.LC6)
 330 03b0 13050400 		addi	a0,s0,%lo(g_uart)
 331 03b4 97000000 		call	UART_send
 331      E7800000 
 332              	.L52:
 333 03bc 13061000 		li	a2,1
 334 03c0 93050102 		addi	a1,sp,32
 335 03c4 13050400 		addi	a0,s0,%lo(g_uart)
 336 03c8 97000000 		call	UART_get_rx
 336      E7800000 
 337 03d0 E30605FE 		beq	a0,zero,.L52
 338 03d4 83270B00 		lw	a5,0(s6)
 339 03d8 03470102 		lbu	a4,32(sp)
 340 03dc 93D6C700 		srli	a3,a5,12
 341 03e0 93D74701 		srli	a5,a5,20
 342 03e4 2302D102 		sb	a3,36(sp)
 343 03e8 A302F102 		sb	a5,37(sp)
 344 03ec 6304571D 		beq	a4,s5,.L151
 345              	.L54:
 346 03f0 13061000 		li	a2,1
 347 03f4 93050102 		addi	a1,sp,32
 348 03f8 13050400 		addi	a0,s0,%lo(g_uart)
 349 03fc 97000000 		call	UART_get_rx
 349      E7800000 
 350 0404 E30605FE 		beq	a0,zero,.L54
 351 0408 83470102 		lbu	a5,32(sp)
 352 040c 23122103 		sh	s2,36(sp)
 353 0410 638E5721 		beq	a5,s5,.L152
 354              	.L62:
 355 0414 13061000 		li	a2,1
 356 0418 93050102 		addi	a1,sp,32
 357 041c 13050400 		addi	a0,s0,%lo(g_uart)
 358 0420 97000000 		call	UART_get_rx
 358      E7800000 
 359 0428 E30605FE 		beq	a0,zero,.L62
 360 042c 83470102 		lbu	a5,32(sp)
 361 0430 63888713 		beq	a5,s8,.L153
 362              	.L70:
 363 0434 13061000 		li	a2,1
 364 0438 93850B00 		addi	a1,s7,%lo(.LC0)
 365 043c 13050400 		addi	a0,s0,%lo(g_uart)
 366 0440 97000000 		call	UART_send
 366      E7800000 
 367              	.L73:
 368 0448 13061000 		li	a2,1
 369 044c 93050102 		addi	a1,sp,32
 370 0450 13050400 		addi	a0,s0,%lo(g_uart)
 371 0454 97000000 		call	UART_get_rx
 371      E7800000 
 372 045c E30605FE 		beq	a0,zero,.L73
 373 0460 93070000 		li	a5,0
 374 0464 63040A02 		beq	s4,zero,.L74
 375 0468 13071000 		li	a4,1
 376              	.L75:
 377 046c B386E900 		add	a3,s3,a4
 378 0470 83C60600 		lbu	a3,0(a3)
 379 0474 13171700 		slli	a4,a4,1
 380 0478 B3C7D700 		xor	a5,a5,a3
 381 047c 93978701 		slli	a5,a5,24
 382 0480 93D78741 		srai	a5,a5,24
 383 0484 E374EAFE 		bleu	a4,s4,.L75
 384 0488 93F7F70F 		andi	a5,a5,0xff
 385              	.L74:
 386 048c 03470102 		lbu	a4,32(sp)
 387 0490 630EF700 		beq	a4,a5,.L154
 388 0494 13061000 		li	a2,1
 389 0498 93050D00 		addi	a1,s10,%lo(.LC7)
 390 049c 13050400 		addi	a0,s0,%lo(g_uart)
 391 04a0 97000000 		call	UART_send
 391      E7800000 
 392 04a8 6FF01FF0 		j	.L51
 393              	.L154:
 394 04ac 83270B00 		lw	a5,0(s6)
 395 04b0 13061000 		li	a2,1
 396 04b4 93850B00 		addi	a1,s7,%lo(.LC0)
 397 04b8 B387B701 		add	a5,a5,s11
 398 04bc 13050400 		addi	a0,s0,%lo(g_uart)
 399 04c0 2320FB00 		sw	a5,0(s6)
 400 04c4 97000000 		call	UART_send
 400      E7800000 
 401              	.L50:
 402 04cc 232AB103 		sw	s11,52(sp)
 403 04d0 83274103 		lw	a5,52(sp)
 404 04d4 6398071C 		bne	a5,zero,.L155
 405              	.L77:
 406 04d8 83278100 		lw	a5,8(sp)
 407 04dc 93051000 		li	a1,1
 408 04e0 93C71700 		xori	a5,a5,1
 409 04e4 2324F100 		sw	a5,8(sp)
 410 04e8 13860700 		mv	a2,a5
 411 04ec 8327C100 		lw	a5,12(sp)
 412 04f0 13850700 		addi	a0,a5,%lo(g_gpio)
 413 04f4 97000000 		call	GPIO_set_output
 413      E7800000 
 414 04fc 83274103 		lw	a5,52(sp)
 415 0500 E39607E6 		bne	a5,zero,.L78
 416 0504 03278101 		lw	a4,24(sp)
 417 0508 83470700 		lbu	a5,0(a4)
 418 050c 93871700 		addi	a5,a5,1
 419 0510 93F7F70F 		andi	a5,a5,0xff
 420 0514 2300F700 		sb	a5,0(a4)
 421 0518 E38E07C8 		beq	a5,zero,.L79
 422              	.L32:
 423 051c 13071000 		li	a4,1
 424 0520 6384E728 		beq	a5,a4,.L156
 425              	.L22:
 426 0524 8320C108 		lw	ra,140(sp)
 427 0528 03248108 		lw	s0,136(sp)
 428 052c 83244108 		lw	s1,132(sp)
 429 0530 03290108 		lw	s2,128(sp)
 430 0534 8329C107 		lw	s3,124(sp)
 431 0538 032A8107 		lw	s4,120(sp)
 432 053c 832A4107 		lw	s5,116(sp)
 433 0540 032B0107 		lw	s6,112(sp)
 434 0544 832BC106 		lw	s7,108(sp)
 435 0548 032C8106 		lw	s8,104(sp)
 436 054c 832C4106 		lw	s9,100(sp)
 437 0550 032D0106 		lw	s10,96(sp)
 438 0554 832DC105 		lw	s11,92(sp)
 439 0558 13010109 		addi	sp,sp,144
 440 055c 67800000 		jr	ra
 441              	.L153:
 442 0560 232C0102 		sw	zero,56(sp)
 443 0564 83278103 		lw	a5,56(sp)
 444 0568 63F22705 		bleu	s2,a5,.L86
 445              	.L72:
 446 056c 23000102 		sb	zero,32(sp)
 447              	.L71:
 448 0570 13061000 		li	a2,1
 449 0574 93050102 		addi	a1,sp,32
 450 0578 13050400 		addi	a0,s0,%lo(g_uart)
 451 057c 97000000 		call	UART_get_rx
 451      E7800000 
 452 0584 E30605FE 		beq	a0,zero,.L71
 453 0588 83278103 		lw	a5,56(sp)
 454 058c 03278103 		lw	a4,56(sp)
 455 0590 83460102 		lbu	a3,32(sp)
 456 0594 B387F900 		add	a5,s3,a5
 457 0598 13071700 		addi	a4,a4,1
 458 059c 232CE102 		sw	a4,56(sp)
 459 05a0 03278103 		lw	a4,56(sp)
 460 05a4 2380D700 		sb	a3,0(a5)
 461 05a8 E36227FD 		bgtu	s2,a4,.L72
 462              	.L86:
 463 05ac 930D0900 		mv	s11,s2
 464 05b0 6FF05FE8 		j	.L70
 465              	.L151:
 466 05b4 13061000 		li	a2,1
 467 05b8 93054102 		addi	a1,sp,36
 468 05bc 13050400 		addi	a0,s0,%lo(g_uart)
 469 05c0 97000000 		call	UART_send
 469      E7800000 
 470 05c8 232C0102 		sw	zero,56(sp)
 471 05cc 83278103 		lw	a5,56(sp)
 472 05d0 63ECF400 		bgtu	a5,s1,.L56
 473              	.L55:
 474 05d4 83278103 		lw	a5,56(sp)
 475 05d8 93871700 		addi	a5,a5,1
 476 05dc 232CF102 		sw	a5,56(sp)
 477 05e0 83278103 		lw	a5,56(sp)
 478 05e4 E3F8F4FE 		bleu	a5,s1,.L55
 479              	.L56:
 480 05e8 13061000 		li	a2,1
 481 05ec 93050102 		addi	a1,sp,32
 482 05f0 13050400 		addi	a0,s0,%lo(g_uart)
 483 05f4 97000000 		call	UART_get_rx
 483      E7800000 
 484 05fc E30605FE 		beq	a0,zero,.L56
 485 0600 83470102 		lbu	a5,32(sp)
 486 0604 638A570B 		beq	a5,s5,.L157
 487              	.L58:
 488 0608 232C0102 		sw	zero,56(sp)
 489 060c 83278103 		lw	a5,56(sp)
 490 0610 E3E0F4DE 		bgtu	a5,s1,.L54
 491              	.L60:
 492 0614 83278103 		lw	a5,56(sp)
 493 0618 93871700 		addi	a5,a5,1
 494 061c 232CF102 		sw	a5,56(sp)
 495 0620 83278103 		lw	a5,56(sp)
 496 0624 E3F8F4FE 		bleu	a5,s1,.L60
 497 0628 6FF09FDC 		j	.L54
 498              	.L152:
 499 062c 13061000 		li	a2,1
 500 0630 93054102 		addi	a1,sp,36
 501 0634 13050400 		addi	a0,s0,%lo(g_uart)
 502 0638 97000000 		call	UART_send
 502      E7800000 
 503              	.L63:
 504 0640 13061000 		li	a2,1
 505 0644 93050102 		addi	a1,sp,32
 506 0648 13050400 		addi	a0,s0,%lo(g_uart)
 507 064c 97000000 		call	UART_get_rx
 507      E7800000 
 508 0654 E30605FE 		beq	a0,zero,.L63
 509 0658 232C0102 		sw	zero,56(sp)
 510 065c 83278103 		lw	a5,56(sp)
 511 0660 63ECF400 		bgtu	a5,s1,.L67
 512              	.L64:
 513 0664 83278103 		lw	a5,56(sp)
 514 0668 93871700 		addi	a5,a5,1
 515 066c 232CF102 		sw	a5,56(sp)
 516 0670 83278103 		lw	a5,56(sp)
 517 0674 E3F8F4FE 		bleu	a5,s1,.L64
 518              	.L67:
 519 0678 83470102 		lbu	a5,32(sp)
 520 067c 638A5705 		beq	a5,s5,.L158
 521              	.L66:
 522 0680 232C0102 		sw	zero,56(sp)
 523 0684 83278103 		lw	a5,56(sp)
 524 0688 E3E6F4D8 		bgtu	a5,s1,.L62
 525              	.L69:
 526 068c 83278103 		lw	a5,56(sp)
 527 0690 93871700 		addi	a5,a5,1
 528 0694 232CF102 		sw	a5,56(sp)
 529 0698 83278103 		lw	a5,56(sp)
 530 069c E3F8F4FE 		bleu	a5,s1,.L69
 531 06a0 6FF05FD7 		j	.L62
 532              	.L155:
 533 06a4 83254103 		lw	a1,52(sp)
 534 06a8 13850900 		mv	a0,s3
 535 06ac 97000000 		call	copy_to_flash
 535      E7800000 
 536 06b4 6FF05FE2 		j	.L77
 537              	.L157:
 538 06b8 13061000 		li	a2,1
 539 06bc 93055102 		addi	a1,sp,37
 540 06c0 13050400 		addi	a0,s0,%lo(g_uart)
 541 06c4 97000000 		call	UART_send
 541      E7800000 
 542 06cc 6FF0DFF3 		j	.L58
 543              	.L158:
 544 06d0 13061000 		li	a2,1
 545 06d4 93055102 		addi	a1,sp,37
 546 06d8 13050400 		addi	a0,s0,%lo(g_uart)
 547 06dc 97000000 		call	UART_send
 547      E7800000 
 548 06e4 6FF0DFF9 		j	.L66
 549              	.L150:
 550 06e8 B7050000 		lui	a1,%hi(.LC4)
 551 06ec 13061000 		li	a2,1
 552 06f0 93850500 		addi	a1,a1,%lo(.LC4)
 553 06f4 13050400 		addi	a0,s0,%lo(g_uart)
 554 06f8 97000000 		call	UART_send
 554      E7800000 
 555 0700 6FF0DFB7 		j	.L43
 556              	.L149:
 557 0704 B7050000 		lui	a1,%hi(.LC3)
 558 0708 13061000 		li	a2,1
 559 070c 93850500 		addi	a1,a1,%lo(.LC3)
 560 0710 13050400 		addi	a0,s0,%lo(g_uart)
 561 0714 97000000 		call	UART_send
 561      E7800000 
 562 071c 6FF0DFB3 		j	.L41
 563              	.L148:
 564 0720 B7050000 		lui	a1,%hi(.LC2)
 565 0724 13061000 		li	a2,1
 566 0728 93850500 		addi	a1,a1,%lo(.LC2)
 567 072c 13050400 		addi	a0,s0,%lo(g_uart)
 568 0730 97000000 		call	UART_send
 568      E7800000 
 569 0738 6FF0DFAF 		j	.L39
 570              	.L146:
 571 073c 13061000 		li	a2,1
 572 0740 93850B00 		addi	a1,s7,%lo(.LC0)
 573 0744 13050400 		addi	a0,s0,%lo(g_uart)
 574 0748 97000000 		call	UART_send
 574      E7800000 
 575 0750 6FF0DFA9 		j	.L35
 576              	.L147:
 577 0754 B7070000 		lui	a5,%hi(.LC1)
 578 0758 13061000 		li	a2,1
 579 075c 93850700 		addi	a1,a5,%lo(.LC1)
 580 0760 13050400 		addi	a0,s0,%lo(g_uart)
 581 0764 97000000 		call	UART_send
 581      E7800000 
 582 076c 6FF05FAA 		j	.L37
 583              	.L145:
 584 0770 8327C100 		lw	a5,12(sp)
 585 0774 13061000 		li	a2,1
 586 0778 93050000 		li	a1,0
 587 077c 13850700 		addi	a0,a5,%lo(g_gpio)
 588 0780 97000000 		call	GPIO_set_output
 588      E7800000 
 589 0788 6FF0DF9D 		j	.L31
 590              	.L144:
 591 078c B70B0000 		lui	s7,%hi(.LC0)
 592 0790 13061000 		li	a2,1
 593 0794 93850B00 		addi	a1,s7,%lo(.LC0)
 594 0798 13050400 		addi	a0,s0,%lo(g_uart)
 595 079c 97000000 		call	UART_send
 595      E7800000 
 596 07a4 6FF0DF8C 		j	.L24
 597              	.L156:
 598 07a8 8327C100 		lw	a5,12(sp)
 599 07ac 13061000 		li	a2,1
 600 07b0 93051000 		li	a1,1
 601 07b4 13850700 		addi	a0,a5,%lo(g_gpio)
 602 07b8 97000000 		call	GPIO_set_output
 602      E7800000 
 603 07c0 6FF05FD6 		j	.L22
 604              	.L81:
 605 07c4 B7070000 		lui	a5,%hi(g_gpio)
 606 07c8 23240100 		sw	zero,8(sp)
 607 07cc 2326F100 		sw	a5,12(sp)
 608 07d0 6FF01F97 		j	.L25
 610              		.section	.text.read_program_from_flash_and_copy_to_ddr,"ax",@progbits
 611              		.align	2
 612              		.globl	read_program_from_flash_and_copy_to_ddr
 614              	read_program_from_flash_and_copy_to_ddr:
 615 0000 B7070000 		lui	a5,%hi(.LANCHOR2)
 616 0004 130101FD 		addi	sp,sp,-48
 617 0008 83A70700 		lw	a5,%lo(.LANCHOR2)(a5)
 618 000c 23202103 		sw	s2,32(sp)
 619 0010 B7050000 		lui	a1,%hi(.LC8)
 620 0014 37090000 		lui	s2,%hi(g_uart)
 621 0018 93850500 		addi	a1,a1,%lo(.LC8)
 622 001c 13050900 		addi	a0,s2,%lo(g_uart)
 623 0020 23220100 		sw	zero,4(sp)
 624 0024 2324F100 		sw	a5,8(sp)
 625 0028 23261102 		sw	ra,44(sp)
 626 002c 23248102 		sw	s0,40(sp)
 627 0030 23229102 		sw	s1,36(sp)
 628 0034 232E3101 		sw	s3,28(sp)
 629 0038 232C4101 		sw	s4,24(sp)
 630 003c 232A5101 		sw	s5,20(sp)
 631 0040 97000000 		call	UART_polled_tx_string
 631      E7800000 
 632 0048 97000000 		call	FLASH_init
 632      E7800000 
 633 0050 97000000 		call	FLASH_global_unprotect
 633      E7800000 
 634 0058 93053100 		addi	a1,sp,3
 635 005c 13052100 		addi	a0,sp,2
 636 0060 97000000 		call	FLASH_read_device_id
 636      E7800000 
 637 0068 23220100 		sw	zero,4(sp)
 638 006c 03274100 		lw	a4,4(sp)
 639 0070 B7071000 		li	a5,1048576
 640 0074 637AF702 		bgeu	a4,a5,.L160
 641 0078 37575555 		li	a4,1431654400
 642 007c 37062080 		li	a2,-2145386496
 643 0080 13075755 		addi	a4,a4,1365
 644 0084 B7061000 		li	a3,1048576
 645              	.L161:
 646 0088 83274100 		lw	a5,4(sp)
 647 008c B387C700 		add	a5,a5,a2
 648 0090 23A0E700 		sw	a4,0(a5)
 649 0094 83274100 		lw	a5,4(sp)
 650 0098 93874700 		addi	a5,a5,4
 651 009c 2322F100 		sw	a5,4(sp)
 652 00a0 83274100 		lw	a5,4(sp)
 653 00a4 E3E2D7FE 		bltu	a5,a3,.L161
 654              	.L160:
 655 00a8 23220100 		sw	zero,4(sp)
 656 00ac 03274100 		lw	a4,4(sp)
 657 00b0 B7071000 		li	a5,1048576
 658 00b4 6374F708 		bgeu	a4,a5,.L162
 659 00b8 37040000 		lui	s0,%hi(g_read_buf)
 660 00bc 9309F00F 		li	s3,255
 661 00c0 930A0400 		addi	s5,s0,%lo(g_read_buf)
 662 00c4 370A2080 		li	s4,-2145386496
 663 00c8 B7041000 		li	s1,1048576
 664              	.L165:
 665 00cc 03258100 		lw	a0,8(sp)
 666 00d0 83274100 		lw	a5,4(sp)
 667 00d4 13060010 		li	a2,256
 668 00d8 93050400 		addi	a1,s0,%lo(g_read_buf)
 669 00dc 3305F500 		add	a0,a0,a5
 670 00e0 97000000 		call	FLASH_read
 670      E7800000 
 671 00e8 23260100 		sw	zero,12(sp)
 672 00ec 8327C100 		lw	a5,12(sp)
 673 00f0 63ECF902 		bgtu	a5,s3,.L163
 674              	.L164:
 675 00f4 0327C100 		lw	a4,12(sp)
 676 00f8 83274100 		lw	a5,4(sp)
 677 00fc 8326C100 		lw	a3,12(sp)
 678 0100 3387EA00 		add	a4,s5,a4
 679 0104 03470700 		lbu	a4,0(a4)
 680 0108 B387D700 		add	a5,a5,a3
 681 010c B3874701 		add	a5,a5,s4
 682 0110 2380E700 		sb	a4,0(a5)
 683 0114 8327C100 		lw	a5,12(sp)
 684 0118 93871700 		addi	a5,a5,1
 685 011c 2326F100 		sw	a5,12(sp)
 686 0120 8327C100 		lw	a5,12(sp)
 687 0124 E3F8F9FC 		bleu	a5,s3,.L164
 688              	.L163:
 689 0128 83274100 		lw	a5,4(sp)
 690 012c 93870710 		addi	a5,a5,256
 691 0130 2322F100 		sw	a5,4(sp)
 692 0134 83274100 		lw	a5,4(sp)
 693 0138 E3EA97F8 		bltu	a5,s1,.L165
 694              	.L162:
 695 013c 03472100 		lbu	a4,2(sp)
 696 0140 93070002 		li	a5,32
 697 0144 6304F702 		beq	a4,a5,.L171
 698              	.L159:
 699 0148 8320C102 		lw	ra,44(sp)
 700 014c 03248102 		lw	s0,40(sp)
 701 0150 83244102 		lw	s1,36(sp)
 702 0154 03290102 		lw	s2,32(sp)
 703 0158 8329C101 		lw	s3,28(sp)
 704 015c 032A8101 		lw	s4,24(sp)
 705 0160 832A4101 		lw	s5,20(sp)
 706 0164 13010103 		addi	sp,sp,48
 707 0168 67800000 		jr	ra
 708              	.L171:
 709 016c B7050000 		lui	a1,%hi(.LC9)
 710 0170 93850500 		addi	a1,a1,%lo(.LC9)
 711 0174 13050900 		addi	a0,s2,%lo(g_uart)
 712 0178 97000000 		call	UART_polled_tx_string
 712      E7800000 
 713 0180 6FF09FFC 		j	.L159
 715              		.section	.text.startup.main,"ax",@progbits
 716              		.align	2
 717              		.globl	main
 719              	main:
 720 0000 37050000 		lui	a0,%hi(g_gpio)
 721 0004 130101ED 		addi	sp,sp,-304
 722 0008 13062000 		li	a2,2
 723 000c B7050075 		li	a1,1962934272
 724 0010 13050500 		addi	a0,a0,%lo(g_gpio)
 725 0014 23261112 		sw	ra,300(sp)
 726 0018 23248112 		sw	s0,296(sp)
 727 001c 23229112 		sw	s1,292(sp)
 728 0020 23202113 		sw	s2,288(sp)
 729 0024 232E3111 		sw	s3,284(sp)
 730 0028 232C4111 		sw	s4,280(sp)
 731 002c 232A5111 		sw	s5,276(sp)
 732 0030 23286111 		sw	s6,272(sp)
 733 0034 23267111 		sw	s7,268(sp)
 734 0038 23248111 		sw	s8,264(sp)
 735 003c 23229111 		sw	s9,260(sp)
 736 0040 37040000 		lui	s0,%hi(g_uart)
 737 0044 97000000 		call	GPIO_init
 737      E7800000 
 738 004c 93061000 		li	a3,1
 739 0050 13064001 		li	a2,20
 740 0054 B7050071 		li	a1,1895825408
 741 0058 13050400 		addi	a0,s0,%lo(g_uart)
 742 005c 97000000 		call	UART_init
 742      E7800000 
 743 0064 B7050000 		lui	a1,%hi(.LANCHOR5)
 744 0068 93850500 		addi	a1,a1,%lo(.LANCHOR5)
 745 006c 13050400 		addi	a0,s0,%lo(g_uart)
 746 0070 97000000 		call	UART_polled_tx_string
 746      E7800000 
 747 0078 37090000 		lui	s2,%hi(.LANCHOR6)
 748 007c 370B0000 		lui	s6,%hi(.LC10)
 749 0080 B70C0000 		lui	s9,%hi(.LC11)
 750 0084 370C0000 		lui	s8,%hi(.LC12)
 751 0088 93041003 		li	s1,49
 752 008c 930A2003 		li	s5,50
 753 0090 930B0008 		li	s7,128
 754 0094 130A3003 		li	s4,51
 755 0098 93090003 		li	s3,48
 756              	.L173:
 757 009c 93050900 		addi	a1,s2,%lo(.LANCHOR6)
 758 00a0 13050400 		addi	a0,s0,%lo(g_uart)
 759 00a4 97000000 		call	UART_polled_tx_string
 759      E7800000 
 760              	.L174:
 761 00ac 13061000 		li	a2,1
 762 00b0 93050100 		mv	a1,sp
 763 00b4 13050400 		addi	a0,s0,%lo(g_uart)
 764 00b8 97000000 		call	UART_get_rx
 764      E7800000 
 765 00c0 E30605FE 		beq	a0,zero,.L174
 766 00c4 9307803E 		li	a5,1000
 767              	.L176:
 768 00c8 9387F7FF 		addi	a5,a5,-1
 769 00cc E39E07FE 		bne	a5,zero,.L176
 770 00d0 93050B00 		addi	a1,s6,%lo(.LC10)
 771 00d4 13050400 		addi	a0,s0,%lo(g_uart)
 772 00d8 97000000 		call	UART_polled_tx_string
 772      E7800000 
 773 00e0 83470100 		lbu	a5,0(sp)
 774 00e4 63869706 		beq	a5,s1,.L177
 775 00e8 63F4F404 		bleu	a5,s1,.L189
 776 00ec 63885701 		beq	a5,s5,.L188
 777 00f0 63964707 		bne	a5,s4,.L180
 778 00f4 97000000 		call	read_program_from_flash_and_copy_to_ddr
 778      E7800000 
 779              	.L188:
 780 00fc 93050C00 		addi	a1,s8,%lo(.LC12)
 781 0100 13050400 		addi	a0,s0,%lo(g_uart)
 782 0104 97000000 		call	UART_polled_tx_string
 782      E7800000 
 783              	 #APP
 784              	# 631 "C:\2023\Microchip_Projects\Design_updates\2023.2\SoftConsole_updated\miv-rv32im-bootloader\m
   0              	
 785              		csrrc a5, mstatus, s7
 786              	# 0 "" 2
 787              	# 632 "C:\2023\Microchip_Projects\Design_updates\2023.2\SoftConsole_updated\miv-rv32im-bootloader\m
 788              		csrrc a5, mstatus, 8
 789              	# 0 "" 2
 790              	# 631 "C:\2023\Microchip_Projects\Design_updates\2023.2\SoftConsole_updated\miv-rv32im-bootloader\m
 791              		csrrc a5, mstatus, s7
 792              	# 0 "" 2
 793              	# 632 "C:\2023\Microchip_Projects\Design_updates\2023.2\SoftConsole_updated\miv-rv32im-bootloader\m
 794              		csrrc a5, mstatus, 8
 795              	# 0 "" 2
 796              	# 650 "../main.c" 1
   1              	/*******************************************************************************
   2              	 * (c) Copyright 2016-2017 Microsemi SoC Products Group. All rights reserved.
   3              	 *
   4              	 *  Simple boot-loader example program.
   5              	 *  This sample project is targeted at a RISC-V design running on the M2S150
   6              	 *  development board.
   7              	 *  You can program the SPI Flash from a command line program and have the
   8              	 *  boot-loader load a program from SPI Flash and jump to it.
   9              	 *  These actions are driven from a serial command line interface.
  10              	 *
  11              	 * SVN $Revision: $
  12              	 * SVN $Date: $
  13              	 */
  14              	#include <unistd.h>
  15              	
  16              	#include "hw_platform.h"
  17              	//#include "riscv_hal.h"
  18              	#include "miv_rv32_hal.h"
  19              	
  20              	
  21              	#include "drivers/CoreGPIO/core_gpio.h"
  22              	#include "drivers/CoreUARTapb/core_uart_apb.h"
  23              	#include "drivers/CoreSPI/core_spi.h"
  24              	
  25              	#include <string.h>
  26              	#include "mt25ql01gbbb.h"
  27              	
  28              	#define FLASH_SECTOR_SIZE   65536 // Sectors are 64K bytes
  29              	#define FLASH_SECTORS       128   // This is an 8MB part with 128 sectors of 64KB
  30              	#define FLASH_BLOCK_SIZE    4096  // We will use the 4K blocks for this example
  31              	#define FLASH_SEGMENT_SIZE  256   // Write segment size
  32              	
  33              	#define FLASH_BLOCK_SEGMENTS ( FLASH_BLOCK_SIZE / FLASH_SEGMENT_SIZE )
  34              	
  35              	#define FLASH_BYTE_SIZE		(FLASH_SECTOR_SIZE * FLASH_SECTORS)
  36              	#define LAST_BLOCK_ADDR     (FLASH_BYTE_SIZE - FLASH_BLOCK_SIZE)
  37              	#define F_P 1
  38              	#define DDR_APP_MAX_SIZE 1024*1024*1 //1MB
  39              	static void Bootloader_JumpToApplication(uint32_t stack_location, uint32_t reset_vector);
  40              	
  41              	
  42              	/*
  43              	 * Data structure stored at the beginning of SPI flash to indicate the suize of
  44              	 * data stored inside the SPI flash. This is to avoid having to read the entire
  45              	 * flash content at boot time.
  46              	 * This data structure is one flash segment long (256 bytes).
  47              	 */
  48              	typedef struct
  49              	{
  50              	    uint32_t validity_key;
  51              	    uint32_t spi_content_byte_size;
  52              	    uint32_t dummy[62];
  53              	} flash_content_t;
  54              	
  55              	/*
  56              	 * Base address of DDR memory where executable will be loaded.
  57              	 */
  58              	#define DDR_BASE_ADDRESS    0x80200000
  59              	
  60              	/*
  61              	 * Delay loop down counter load value.
  62              	 */
  63              	#define DELAY_LOAD_VALUE     0x00008000
  64              	
  65              	/*
  66              	 * Bit mask identifying the DIP switch used to indicate whether the boot loader
  67              	 * should load and launch the application on system reset or stay running to
  68              	 * allow a new image to be programming into the SPI flash.
  69              	 */
  70              	#define BOOTLOADER_DIP_SWITCH   0x00000080
  71              	
  72              	/*
  73              	 * Key value used to determine if valid data is contained in the SPI flash.
  74              	 */
  75              	#define SPI_FLASH_VALID_CONTENT_KEY     0xB5006BB1
  76              	
  77              	/*
  78              	 * CoreGPIO instance data.
  79              	 */
  80              	gpio_instance_t g_gpio;
  81              	
  82              	volatile uint32_t g_10ms_count;
  83              	volatile uint32_t g_state;
  84              	
  85              	/////////////////
  86              	#define BUFFER_SIZE 4096
  87              	
  88              	void delay1(volatile uint32_t n)
  89              	{
  90              		while(n)
  91              			n--;
  92              	}
  93              	//extern void delay(volatile int i);
  94              	//*&************************************************************
  95              	uint8_t g_write_buffer[BUFFER_SIZE];
  96              	uint8_t no_of_files =0;
  97              	uint32_t flash_address[3] = {0x1000,0xA00000,0x1400000};
  98              	uint8_t g_read_buf[BUFFER_SIZE];
  99              	uint32_t g_src_image_target_address =0;
 100              	uint32_t g_file_size = 0;
 101              	uint32_t g_flash_address = 0;
 102              	#define MAX_FILES 1
 103              	///////////////
 104              	/******************************************************************************
 105              	 * Maximum receiver buffer size.
 106              	 *****************************************************************************/
 107              	#define MAX_RX_DATA_SIZE    256
 108              	
 109              	/******************************************************************************
 110              	 * CoreUARTapb instance data.
 111              	 *****************************************************************************/
 112              	UART_instance_t g_uart;
 113              	
 114              	/******************************************************************************
 115              	 * Instruction message. This message will be transmitted over the UART to
 116              	 * HyperTerminal when the program starts.
 117              	 *****************************************************************************/
 118              	const uint8_t g_greeting_msg[] =
 119              	"\r\n\r\n\
 120              	===============================================================================\r\n\
 121              	                    Microsemi Mi-V Boot Loader v1.0.0\r\n\
 122              	===============================================================================\r\n\
 123              	 This boot loader provides the following features:\r\n\
 124              	    - Load a program into SPI Flash memory using UART.\r\n\
 125              	    - Load a program from SPI flash into external DDR memory \r\n\
 126              	    - Launch the loaded program from DDR.\r\n\
 127              	 ";
 128              	
 129              	const uint8_t g_instructions_msg[] =
 130              	"\r\n\r\n\
 131              	-------------------------------------------------------------------------------\r\n\
 132              	 Options:\n\r\
 133              	 Type 0 to program flash with application image \n\r\
 134              	 Type 1 to copy program from flash to DDR \n\r\
 135              	 Type 2 to start program loaded in DDR \n\r\
 136              	 Type 3 to copy program from flash to DDR and launch the program from DDR \n\r\
 137              	";
 138              	
 139              	
 140              	
 141              	
 142              	
 143              	const uint8_t g_load_executable_msg[] =
 144              	"\r\n\
 145              	-------------------------------------------------------------------------------\r\n\
 146              	 Loading application from SPI flash into DDR memory.\r\n";
 147              	
 148              	const uint8_t g_run_executable_msg[] =
 149              	"\r\n\
 150              	-------------------------------------------------------------------------------\r\n\
 151              	 Executing application in DDR memory.\r\n\
 152              	-------------------------------------------------------------------------------\r\n\
 153              	 \r\n";
 154              	
 155              	
 156              	/******************************************************************************
 157              	 * GPIO instance data.
 158              	 *****************************************************************************/
 159              	gpio_instance_t g_gpio;
 160              	
 161              	/*-------------------------------------------------------------------------*//**
 162              	 * main() function.
 163              	 */
 164              	#if F_P
 165              	static uint32_t read_page_from_host_through_uart
 166              	(
 167              			uint8_t * g_buffer,
 168              			uint32_t length
 169              	)
 170              	{
 171              		uint32_t num_bytes,factor,temp;
 172              		volatile uint32_t i = 0;
 173              		num_bytes = length;
 174              		char crc;
 175              		size_t rx_size = 0;
 176              	
 177              	
 178              		uint8_t rx_buff[1],temp_add[2];
 179              		//Write Ack "b" to indicate beginning of the transaction from the target
 180              	
 181              		if(g_src_image_target_address + length > g_file_size )
 182              		{
 183              			num_bytes = g_file_size - g_src_image_target_address;
 184              		}
 185              		if(g_src_image_target_address>= g_file_size)
 186              		{
 187              			return 0;
 188              		}
 189              		CRCFAIL:
 190              	
 191              	
 192              		UART_send(&g_uart, (const uint8_t * )"b",1);
 193              		//poll for Ack message from the host as an acknowledgment that the host is ready for receiving the
 194              	
 195              		while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 196              			;
 197              	
 198              	#if 1
 199              		temp = g_src_image_target_address/4096;
 200              		temp_add[0] = temp&0xFF;
 201              		temp_add[1] = (temp>>8)&0xFF;
 202              		if(rx_buff[0]== 'a')
 203              		{
 204              			UART_send(&g_uart,&temp_add[0],1);
 205              			for(i=0;i<500;i++);
 206              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 207              				;
 208              	
 209              			if(rx_buff[0]== 'a')
 210              				UART_send(&g_uart,&temp_add[1],1);
 211              			for(i=0;i<500;i++);
 212              	
 213              		}
 214              	
 215              	
 216              		while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 217              			;
 218              	#endif
 219              	
 220              		temp_add[0] = num_bytes&0xFF;
 221              		temp_add[1] = (num_bytes>>8)&0xFF;
 222              		if(rx_buff[0]== 'a')
 223              		{
 224              	
 225              			UART_send(&g_uart,&temp_add[0],1);
 226              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 227              				;
 228              			for(i=0;i<500;i++);
 229              			if(rx_buff[0]== 'a')
 230              				UART_send(&g_uart,&temp_add[1],1);
 231              			for(i=0;i<500;i++);
 232              		}
 233              	
 234              		//poll for Ack message from the host as an acknowledgment that the host received the return bytes
 235              		while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 236              			;
 237              	
 238              	#if 1
 239              		if(rx_buff[0]== 'n')
 240              		{
 241              			for(i=0;i<num_bytes;i++)
 242              			{
 243              				rx_buff[0] = 0;
 244              				while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 245              					;
 246              				g_buffer[i] = rx_buff[0];
 247              	
 248              			}
 249              			rx_size = num_bytes;
 250              		}
 251              	#endif
 252              	
 253              	
 254              		UART_send(&g_uart, (const uint8_t * )"a",1);
 255              	
 256              		while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 257              			;
 258              		factor = 1;
 259              		crc = 0;
 260              		while((num_bytes-1)/factor)
 261              		{
 262              			crc = crc^g_buffer[factor];
 263              			factor = factor*2;
 264              		}
 265              		if(crc == (char)rx_buff[0])
 266              		{
 267              			g_src_image_target_address += rx_size;
 268              	
 269              			UART_send(&g_uart, (const uint8_t * )"a",1);
 270              		}
 271              		else
 272              		{
 273              			UART_send(&g_uart,(const uint8_t * )"n",1);
 274              			goto CRCFAIL;
 275              		}
 276              	
 277              		return rx_size;
 278              	}
 279              	uint32_t number_size(uint8_t *ptr)
 280              	{
 281              		uint32_t temp = 0,i=0;
 282              		while(*ptr != '\0' && i<9)
 283              		{
 284              			temp = temp*10+*ptr -'0';
 285              			ptr++;
 286              			i++;
 287              		}
 288              		return temp;
 289              	}
 290              	void copy_to_flash(uint8_t * g_buffer,uint32_t length)
 291              	{
 292              		uint32_t i=0;
 293              		for(i=0;i<8;i++)
 294              		{
 295              			FLASH_program(g_flash_address+i*512 , &g_buffer[i*512], 512);
 296              		}
 297              		g_flash_address = g_flash_address + BUFFER_SIZE;
 298              	}
 299              	
 300              	void load_spi_flash_with_images_thruough_uart_intf()
 301              	{
 302              		volatile uint32_t erase_address = 0;
 303              		volatile uint32_t erase_count=0;
 304              		volatile uint32_t i = 0,length = 0;
 305              	
 306              	
 307              		uint8_t rx_buff[8],num[9];
 308              		uint8_t  manufacturer_id;
 309              		uint8_t  device_id,led_state = 0;
 310              	
 311              	
 312              		while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 313              			;
 314              		if(rx_buff[0] == 's') //signal from host PC to proceed to erase the flash.
 315              			UART_send(&g_uart, (const uint8_t * )"a",1);
 316              	
 317              		FLASH_init();
 318              	
 319              		FLASH_global_unprotect();
 320              		FLASH_read_device_id
 321              		(
 322              				&manufacturer_id,
 323              				&device_id
 324              		);
 325              		//UART_init( &g_uart, COREUARTAPB0_BASE_ADDR, 59, (DATA_8_BITS | NO_PARITY) );
 326              	
 327              	
 328              		erase_address = erase_count = 0;
 329              		for(erase_count = 0;erase_count<=16;erase_count++)  //1MB erase 64
 330              		{
 331              			GPIO_set_output( &g_gpio, GPIO_0,led_state);
 332              			FLASH_erase_64k_block(erase_address);
 333              			delay1(500);
 334              			FLASH_read(erase_address,g_read_buf,32);
 335              			erase_address+=0x10000;
 336              			if(g_read_buf[0] != 0xFF)
 337              			{
 338              	
 339              				break;
 340              			}
 341              			led_state = led_state ^ 1;
 342              		}
 343              		if(erase_count == 5)
 344              		{
 345              			GPIO_set_output( &g_gpio, GPIO_0,1); //erase successful
 346              		}
 347              		else
 348              		{
 349              			GPIO_set_output( &g_gpio, GPIO_0,0); //erase failed
 350              		}
 351              	
 352              	
 353              	#if 1
 354              		while(no_of_files<MAX_FILES)
 355              		{
 356              	
 357              			g_flash_address = flash_address[no_of_files];
 358              			g_src_image_target_address = 0;
 359              			/* start the handshake with the host */
 360              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 361              				;
 362              			if(rx_buff[0] == 'h')
 363              				UART_send(&g_uart, (const uint8_t * )"a",1);
 364              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 365              				;
 366              			if(rx_buff[0] == 'n')
 367              				UART_send(&g_uart, (const uint8_t * )"d", 1 );
 368              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 369              				;
 370              			if(rx_buff[0] == 's')
 371              				UART_send(&g_uart, (const uint8_t * )"h", 1 );
 372              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 373              				;
 374              			if(rx_buff[0] == 'a')
 375              				UART_send(&g_uart, (const uint8_t * )"k", 1 );
 376              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 377              				;
 378              			if(rx_buff[0] == 'e')
 379              			{
 380              				UART_send(&g_uart, (const uint8_t * )"r", 1 );
 381              			}
 382              			/* poll for starting Ack message from the host as an acknowledgment
 383              			                   that the host is ready to send file size */
 384              	
 385              			while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 386              				;
 387              			UART_send(&g_uart, (const uint8_t * )"a",1);
 388              	
 389              	
 390              			/*poll for file size*/
 391              			UART_send(&g_uart, (const uint8_t * )"z",1);
 392              			i=0;
 393              			while(i<9)
 394              			{
 395              				while(!(UART_get_rx ( &g_uart, rx_buff, 1 )))
 396              					;
 397              	
 398              				num[i] = rx_buff[0];
 399              				i++;
 400              			}
 401              			g_file_size = number_size(num);//;atoi((const char*)rx_buff);
 402              	
 403              			UART_send(&g_uart, (const uint8_t * )"a",1);
 404              	
 405              			do
 406              			{
 407              				length = read_page_from_host_through_uart(g_write_buffer, BUFFER_SIZE);
 408              				if(length>0)
 409              				{
 410              					copy_to_flash(g_write_buffer,length);
 411              					//memcpy(ddr_add1,g_page_buffer,length);
 412              					//ddr_add1 +=  length;
 413              				}
 414              				led_state = led_state ^ 1;
 415              				GPIO_set_output( &g_gpio, GPIO_1,led_state);
 416              			}while(length!=0);
 417              			//ddr_add += 0x30000;
 418              	
 419              			no_of_files++;
 420              		}
 421              		if(no_of_files==MAX_FILES)
 422              		{
 423              			GPIO_set_output( &g_gpio, GPIO_1,1);
 424              		}
 425              	#endif
 426              	}
 427              	#endif
 428              	#if 1
 429              	void read_program_from_flash_and_copy_to_ddr()
 430              	{
 431              		volatile uint32_t i=0,address=flash_address[0],j;
 432              		uint8_t manufacturer_id,device_id;
 433              		UART_polled_tx_string( &g_uart, ( uint8_t*)"\n\rApplication copying to DDR from SPI flash is in pr
 434              		FLASH_init();
 435              		FLASH_global_unprotect();
 436              		FLASH_read_device_id
 437              		(
 438              				&manufacturer_id,
 439              				&device_id
 440              		);
 441              		//ddr memory initialization with 0x55
 442              		for(i=0;i<DDR_APP_MAX_SIZE;i=i+4)
 443              		{
 444              			*(volatile uint32_t*)(DDR_BASE_ADDRESS+i) = 0x55555555;
 445              		}
 446              		for(i=0;i<DDR_APP_MAX_SIZE;i=i+FLASH_SEGMENT_SIZE)
 447              		{
 448              			FLASH_read(address+i , &g_read_buf[0], FLASH_SEGMENT_SIZE);
 449              			//memcpy((uint8_t*)(DDR_BASE_ADDRESS+i),&g_read_buf[0],FLASH_SEGMENT_SIZE);
 450              			for(j=0;j<FLASH_SEGMENT_SIZE;j++)
 451              			{
 452              				*(volatile uint8_t*)(DDR_BASE_ADDRESS+i+j) = g_read_buf[j];
 453              			}
 454              		}
 455              		if(manufacturer_id == 0x20)
 456              		{
 457              			UART_polled_tx_string( &g_uart, ( uint8_t*)"\n\rApplication Successfully copied to DDR from SPI f
 458              		}
 459              	
 460              	
 461              	}
 462              	#endif
 463              	
 464              	int main()
 465              	{
 466              		uint8_t rx_data[MAX_RX_DATA_SIZE];
 467              		size_t rx_size;
 468              		char wait_in_bl;
 469              	
 470              		GPIO_init( &g_gpio, COREGPIO_OUT_BASE_ADDR, GPIO_APB_32_BITS_BUS );
 471              	
 472              	 // flash_check();
 473              	 // while(1);
 474              	
 475              	
 476              	    /**************************************************************************
 477              	      * Initialize CoreUARTapb with its base address, baud value, and line
 478              	      * configuration.
 479              	      *************************************************************************/
 480              		UART_init( &g_uart, COREUARTAPB0_BASE_ADDR,\
 481              				BAUD_VALUE_115200, (DATA_8_BITS | NO_PARITY) );
 482              	
 483              	
 484              	
 485              	    /**************************************************************************
 486              	     * Display greeting message message.
 487              	     *************************************************************************/
 488              		UART_polled_tx_string( &g_uart, g_greeting_msg);
 489              	
 490              		/*uint8_t  manufacturer_id;
 491              		uint8_t  device_id = 0;
 492              		uint8_t  length = 16;
 493              		uint8_t  temp_write_buffer[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
 494              		uint8_t  temp_read_buf[16] = {0};
 495              		FLASH_init();
 496              	
 497              		FLASH_global_unprotect();
 498              		FLASH_read_device_id
 499              		(
 500              				&manufacturer_id,
 501              				&device_id
 502              		);
 503              	
 504              		//FLASH_erase_64k_block(0);
 505              	
 506              		copy_to_flash(temp_write_buffer,length);
 507              	
 508              		FLASH_read(0,temp_read_buf,16);*/
 509              	
 510              	
 511              	#if 0
 512              	
 513              		uint32_t temp[16] = {0};
 514              		uint32_t *p=0x80200000;
 515              		uint32_t i = 5;
 516              	
 517              		for (i=0;i<16*1024;i++)
 518              	    {
 519              			*p = i;
 520              			p++;
 521              	    }
 522              	
 523              	    p=0x80200000;
 524              	
 525              	   // temp =  *(volatile uint32_t*)(DDR_BASE_ADDRESS);
 526              	    for (i=0;i<16*1024;i++)
 527              	    {
 528              	    	//temp[i] = *p;
 529              	    	if((*p) != i)
 530              	    	{
 531              	    		break;
 532              	    	}
 533              	    	p++;
 534              	    }
 535              	    temp[5] = 10;
 536              	    temp[7] = 100;
 537              	
 538              	#endif
 539              	
 540              		while(1)
 541              	    {
 542              	
 543              	         /**********************************************************************
 544              	         * Read data received by the UART.
 545              	         *********************************************************************/
 546              	    	UART_polled_tx_string( &g_uart, g_instructions_msg);
 547              	    	while(!(UART_get_rx ( &g_uart, rx_data, 1 )))
 548              	    			;
 549              	    	  /**********************************************************************
 550              	         * Echo back data received, if any.
 551              	         *********************************************************************/
 552              	
 553              	
 554              	        {
 555              	            //UART_send( &g_uart, rx_data, 1 );
 556              	    		delay1(1000);
 557              	            UART_polled_tx_string( &g_uart, (uint8_t*)"\n\r");
 558              	            switch(rx_data[0])
 559              	            {
 560              	                case '0':
 561              	                	UART_polled_tx_string( &g_uart, (uint8_t*)"******** Initiate SPI Programming *****
 562              	                	load_spi_flash_with_images_thruough_uart_intf();
 563              	                    break;
 564              	                case '1': // transfer file to DDR
 565              	                	read_program_from_flash_and_copy_to_ddr();
 566              	                    break;
 567              	                case '2':
 568              	                	UART_polled_tx_string( &g_uart, (uint8_t*)"Application Execution control will be t
 569              	                	Bootloader_JumpToApplication((uint32_t)0x80200000, (uint32_t)0x80200004);
 570              	                    break;
 571              	                case '3':
 572              	                	read_program_from_flash_and_copy_to_ddr();
 573              	                	UART_polled_tx_string( &g_uart, (uint8_t*)"Application Execution control will be t
 574              						Bootloader_JumpToApplication((uint32_t)0x80200000, (uint32_t)0x80200004);
 575              						break;
 576              	                default:
 577              	                	UART_polled_tx_string( &g_uart, g_instructions_msg);
 578              	                	 break;
 579              	
 580              	
 581              	            }
 582              	        }
 583              	
 584              	    }
 585              	
 586              	
 587              	    while(1);
 588              	    return 0;
 589              	}
 590              	
 591              	/*
 592              	 *  Write to flash on RTG4 Evaluation Kit
 593              	 */
 594              	
 595              	
 596              	/**
 597              	 *  Read from flash
 598              	 */
 599              	
 600              	
 601              	
 602              	#if 0
 603              	/*------------------------------------------------------------------------------
 604              	 * Count the number of elapsed milliseconds (SysTick_Handler is called every
 605              	 * 10mS so the resolution will be 10ms). Rolls over every 49 days or so...
 606              	 *
 607              	 * Should be safe to read g_10ms_count from elsewhere.
 608              	 */
 609              	void SysTick_Handler( void )
 610              	{
 611              	//    uint32_t gpio_pattern;
 612              	//    static uint8_t count;
 613              	//    /*
 614              	//     * Toggle GPIO output pattern by doing an exclusive OR of all
 615              	//     * pattern bits with ones.
 616              	//     */
 617              	//    if(count++>=50)
 618              	//    {
 619              	//        gpio_pattern = GPIO_get_outputs( &g_gpio );
 620              	//        gpio_pattern ^= 0x00000002;
 621              	//        GPIO_set_outputs( &g_gpio, gpio_pattern );
 622              	//        count=0;
 623              	//    }
 624              	
 625              	    g_10ms_count += 10;
 626              	
 627              	     /*
 628              	      * For neatness, if we roll over, reset cleanly back to 0 so the count
 629              	      * always goes up in proper 10s.
 630              	      */
 631              	    if(g_10ms_count < 10)
 632              	        g_10ms_count = 0;
 633              	}
 634              	#endif
 635              	/*------------------------------------------------------------------------------
 636              	 /*------------------------------------------------------------------------------
 637              	* Call this function if you want to switch to another program
 638              	* de-init any loaded drivers before calling this function
 639              	*/
 640              	
 641              	static void Bootloader_JumpToApplication(uint32_t stack_location, uint32_t reset_vector)
 642              	{
 643              	               /* Restore PLIC to known state: */
 644              	               //__disable_irq(); org
 645              					MRV_disable_interrupts();
 646              	               // PLIC_init(); org
 647              	               MRV_disable_interrupts();
 648              	
 649              	               /* Disable all interrupts: */
 650 011c 73504030 	               write_csr(mie, 0);
 651              	
 797              		csrw mie, 0
 798              	# 0 "" 2
 799              	# 653 "../main.c" 1
 652              	               /* Start executing from the top of DDR memory: */
 653 0120 B7002080 	               __asm volatile("lui ra,0x80200");
 654              	
 800              		lui ra,0x80200
 801              	# 0 "" 2
 802              	# 658 "../main.c" 1
 655              	    /*
 656              	     * Flush the cache.
 657              	     */
 658 0124 0F100000 	               __asm volatile ("fence.i");
 659              	
 803              		fence.i
 804              	# 0 "" 2
 805              	# 665 "../main.c" 1
 660              	    /*
 661              	     * We need to explicitly execute a return instruction in case the compiler had
 662              	     * done some return address register manipulation in this function's veneer.
 663              	     */
 664              	
 665 0128 67800000 	               __asm volatile("ret");
 666              	
 806              		ret
 807              	# 0 "" 2
 808              	 #NO_APP
 809 012c 6FF01FF7 		j	.L173
 810              	.L189:
 811 0130 63963703 		bne	a5,s3,.L180
 812 0134 93850C00 		addi	a1,s9,%lo(.LC11)
 813 0138 13050400 		addi	a0,s0,%lo(g_uart)
 814 013c 97000000 		call	UART_polled_tx_string
 814      E7800000 
 815 0144 97000000 		call	load_spi_flash_with_images_thruough_uart_intf
 815      E7800000 
 816 014c 6FF01FF5 		j	.L173
 817              	.L177:
 818 0150 97000000 		call	read_program_from_flash_and_copy_to_ddr
 818      E7800000 
 819 0158 6FF05FF4 		j	.L173
 820              	.L180:
 821 015c 93050900 		addi	a1,s2,%lo(.LANCHOR6)
 822 0160 13050400 		addi	a0,s0,%lo(g_uart)
 823 0164 97000000 		call	UART_polled_tx_string
 823      E7800000 
 824 016c 6FF01FF3 		j	.L173
 826              		.globl	g_run_executable_msg
 827              		.globl	g_load_executable_msg
 828              		.globl	g_instructions_msg
 829              		.globl	g_greeting_msg
 830              		.comm	g_uart,8,4
 831              		.globl	g_flash_address
 832              		.globl	g_file_size
 833              		.globl	g_src_image_target_address
 834              		.comm	g_read_buf,4096,4
 835              		.globl	flash_address
 836              		.globl	no_of_files
 837              		.comm	g_write_buffer,4096,4
 838              		.comm	g_state,4,4
 839              		.comm	g_10ms_count,4,4
 840              		.comm	g_gpio,8,4
 841              		.comm	MRV_LOCAL_IRQn_Type,4,4
 842              		.section	.data.flash_address,"aw"
 843              		.align	2
 844              		.set	.LANCHOR2,. + 0
 847              	flash_address:
 848 0000 00100000 		.word	4096
 849 0004 0000A000 		.word	10485760
 850 0008 00004001 		.word	20971520
 851              		.section	.rodata.g_greeting_msg,"a"
 852              		.align	2
 853              		.set	.LANCHOR5,. + 0
 856              	g_greeting_msg:
 857 0000 0D0A0D0A 		.ascii	"\r\n\r\n===================================================="
 857      3D3D3D3D 
 857      3D3D3D3D 
 857      3D3D3D3D 
 857      3D3D3D3D 
 858 0038 3D3D3D3D 		.ascii	"===========================\r\n                    Microsemi"
 858      3D3D3D3D 
 858      3D3D3D3D 
 858      3D3D3D3D 
 858      3D3D3D3D 
 859 0072 204D692D 		.ascii	" Mi-V Boot Loader v1.0.0\r\n================================"
 859      5620426F 
 859      6F74204C 
 859      6F616465 
 859      72207631 
 860 00ac 3D3D3D3D 		.ascii	"========"
 860      3D3D3D3D 
 861 00b4 3D3D3D3D 		.string	"=======================================\r\n This boot loader provides the following featu
 861      3D3D3D3D 
 861      3D3D3D3D 
 861      3D3D3D3D 
 861      3D3D3D3D 
 862              		.section	.rodata.g_instructions_msg,"a"
 863              		.align	2
 864              		.set	.LANCHOR6,. + 0
 867              	g_instructions_msg:
 868 0000 0D0A0D0A 		.ascii	"\r\n\r\n-----------------------------------------------"
 868      2D2D2D2D 
 868      2D2D2D2D 
 868      2D2D2D2D 
 868      2D2D2D2D 
 869 0033 2D2D2D2D 		.string	"--------------------------------\r\n Options:\n\r Type 0 to program flash with applicatio
 869      2D2D2D2D 
 869      2D2D2D2D 
 869      2D2D2D2D 
 869      2D2D2D2D 
 870              		.section	.rodata.g_load_executable_msg,"a"
 871              		.align	2
 874              	g_load_executable_msg:
 875 0000 0D0A2D2D 		.string	"\r\n-------------------------------------------------------------------------------\r\n L
 875      2D2D2D2D 
 875      2D2D2D2D 
 875      2D2D2D2D 
 875      2D2D2D2D 
 876              		.section	.rodata.g_run_executable_msg,"a"
 877              		.align	2
 880              	g_run_executable_msg:
 881 0000 0D0A2D2D 		.string	"\r\n-------------------------------------------------------------------------------\r\n E
 881      2D2D2D2D 
 881      2D2D2D2D 
 881      2D2D2D2D 
 881      2D2D2D2D 
 882              		.section	.rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4,"aMS",@progbits,1
 883              		.align	2
 884              	.LC0:
 885 0000 6100     		.string	"a"
 886 0002 0000     		.zero	2
 887              	.LC1:
 888 0004 6400     		.string	"d"
 889 0006 0000     		.zero	2
 890              	.LC2:
 891 0008 6800     		.string	"h"
 892 000a 0000     		.zero	2
 893              	.LC3:
 894 000c 6B00     		.string	"k"
 895 000e 0000     		.zero	2
 896              	.LC4:
 897 0010 7200     		.string	"r"
 898 0012 0000     		.zero	2
 899              	.LC5:
 900 0014 7A00     		.string	"z"
 901 0016 0000     		.zero	2
 902              	.LC6:
 903 0018 6200     		.string	"b"
 904 001a 0000     		.zero	2
 905              	.LC7:
 906 001c 6E00     		.string	"n"
 907              		.section	.rodata.main.str1.4,"aMS",@progbits,1
 908              		.align	2
 909              	.LC10:
 910 0000 0A0D00   		.string	"\n\r"
 911 0003 00       		.zero	1
 912              	.LC11:
 913 0004 2A2A2A2A 		.string	"******** Initiate SPI Programming ******\n\r"
 913      2A2A2A2A 
 913      20496E69 
 913      74696174 
 913      65205350 
 914 002f 00       		.zero	1
 915              	.LC12:
 916 0030 4170706C 		.string	"Application Execution control will be transferred to DDR\n\r"
 916      69636174 
 916      696F6E20 
 916      45786563 
 916      7574696F 
 917              		.section	.rodata.read_program_from_flash_and_copy_to_ddr.str1.4,"aMS",@progbits,1
 918              		.align	2
 919              	.LC8:
 920 0000 0A0D4170 		.string	"\n\rApplication copying to DDR from SPI flash is in progress...\n\r"
 920      706C6963 
 920      6174696F 
 920      6E20636F 
 920      7079696E 
 921              	.LC9:
 922 0040 0A0D4170 		.string	"\n\rApplication Successfully copied to DDR from SPI flash\n\r"
 922      706C6963 
 922      6174696F 
 922      6E205375 
 922      63636573 
 923              		.section	.sbss.g_file_size,"aw",@nobits
 924              		.align	2
 925              		.set	.LANCHOR4,. + 0
 928              	g_file_size:
 929 0000 00000000 		.zero	4
 930              		.section	.sbss.g_flash_address,"aw",@nobits
 931              		.align	2
 932              		.set	.LANCHOR0,. + 0
 935              	g_flash_address:
 936 0000 00000000 		.zero	4
 937              		.section	.sbss.g_src_image_target_address,"aw",@nobits
 938              		.align	2
 939              		.set	.LANCHOR3,. + 0
 942              	g_src_image_target_address:
 943 0000 00000000 		.zero	4
 944              		.section	.sbss.no_of_files,"aw",@nobits
 945              		.set	.LANCHOR1,. + 0
 948              	no_of_files:
 949 0000 00       		.zero	1
 950              		.ident	"GCC: (xPack GNU RISC-V Embedded GCC (Microsemi SoftConsole build), 64-bit) 8.3.0"
DEFINED SYMBOLS
                            *ABS*:0000000000000000 main.c
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:11     .text.delay1:0000000000000000 delay1
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:30     .text.number_size:0000000000000000 number_size
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:56     .text.copy_to_flash:0000000000000000 copy_to_flash
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:91     .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000000 load_spi_flash_with_images_thruough_uart_intf
                            *COM*:0000000000000008 g_uart
                            *COM*:0000000000001000 g_read_buf
                            *COM*:0000000000000008 g_gpio
                            *COM*:0000000000001000 g_write_buffer
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:614    .text.read_program_from_flash_and_copy_to_ddr:0000000000000000 read_program_from_flash_and_copy_to_ddr
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:719    .text.startup.main:0000000000000000 main
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:880    .rodata.g_run_executable_msg:0000000000000000 g_run_executable_msg
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:874    .rodata.g_load_executable_msg:0000000000000000 g_load_executable_msg
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:867    .rodata.g_instructions_msg:0000000000000000 g_instructions_msg
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:856    .rodata.g_greeting_msg:0000000000000000 g_greeting_msg
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:935    .sbss.g_flash_address:0000000000000000 g_flash_address
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:928    .sbss.g_file_size:0000000000000000 g_file_size
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:942    .sbss.g_src_image_target_address:0000000000000000 g_src_image_target_address
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:847    .data.flash_address:0000000000000000 flash_address
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:948    .sbss.no_of_files:0000000000000000 no_of_files
                            *COM*:0000000000000004 g_state
                            *COM*:0000000000000004 g_10ms_count
                            *COM*:0000000000000004 MRV_LOCAL_IRQn_Type
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:844    .data.flash_address:0000000000000000 .LANCHOR2
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:853    .rodata.g_greeting_msg:0000000000000000 .LANCHOR5
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:864    .rodata.g_instructions_msg:0000000000000000 .LANCHOR6
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:925    .sbss.g_file_size:0000000000000000 .LANCHOR4
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:932    .sbss.g_flash_address:0000000000000000 .LANCHOR0
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:939    .sbss.g_src_image_target_address:0000000000000000 .LANCHOR3
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:945    .sbss.no_of_files:0000000000000000 .LANCHOR1
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:22     .text.delay1:0000000000000024 .L1
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:16     .text.delay1:0000000000000010 .L3
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:47     .text.number_size:000000000000003c .L13
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:49     .text.number_size:0000000000000040 .L10
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:36     .text.number_size:0000000000000014 .L12
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:68     .text.copy_to_flash:000000000000002c .L19
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:884    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:0000000000000000 .LC0
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:905    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:000000000000001c .LC7
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:899    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:0000000000000014 .LC5
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:902    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:0000000000000018 .LC6
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:896    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:0000000000000010 .LC4
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:893    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:000000000000000c .LC3
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:890    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:0000000000000008 .LC2
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:887    .rodata.load_spi_flash_with_images_thruough_uart_intf.str1.4:0000000000000004 .LC1
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:111    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000004c .L23
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:590    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000078c .L144
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:604    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000007c4 .L81
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:149    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000000f0 .L26
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:169    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000140 .L25
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:140    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000000c8 .L29
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:583    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000770 .L145
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:422    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000051c .L32
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:205    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000001c8 .L33
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:570    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000073c .L146
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:214    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000001ec .L35
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:576    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000754 .L147
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:223    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000210 .L37
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:563    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000720 .L148
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:232    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000234 .L39
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:556    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000704 .L149
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:241    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000258 .L41
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:549    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000006e8 .L150
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:250    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000027c .L43
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:286    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000314 .L48
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:270    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000002d4 .L47
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:302    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000034c .L46
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:292    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000328 .L45
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:320    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000390 .L49
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:401    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000004cc .L50
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:332    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000003bc .L52
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:465    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000005b4 .L151
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:345    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000003f0 .L54
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:498    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000062c .L152
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:354    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000414 .L62
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:441    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000560 .L153
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:367    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000448 .L73
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:385    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000048c .L74
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:376    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000046c .L75
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:393    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000004ac .L154
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:327    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000003a8 .L51
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:532    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000006a4 .L155
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:310    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000036c .L78
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:199    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000001b4 .L79
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:597    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000007a8 .L156
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:462    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000005ac .L86
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:447    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000570 .L71
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:445    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000056c .L72
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:362    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000434 .L70
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:479    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000005e8 .L56
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:473    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000005d4 .L55
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:537    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000006b8 .L157
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:491    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000614 .L60
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:503    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000640 .L63
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:518    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000678 .L67
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:512    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000664 .L64
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:543    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000006d0 .L158
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:525    .text.load_spi_flash_with_images_thruough_uart_intf:000000000000068c .L69
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:405    .text.load_spi_flash_with_images_thruough_uart_intf:00000000000004d8 .L77
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:487    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000608 .L58
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:521    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000680 .L66
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:178    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000164 .L31
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:120    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000070 .L24
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:425    .text.load_spi_flash_with_images_thruough_uart_intf:0000000000000524 .L22
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:919    .rodata.read_program_from_flash_and_copy_to_ddr.str1.4:0000000000000000 .LC8
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:921    .rodata.read_program_from_flash_and_copy_to_ddr.str1.4:0000000000000040 .LC9
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:654    .text.read_program_from_flash_and_copy_to_ddr:00000000000000a8 .L160
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:645    .text.read_program_from_flash_and_copy_to_ddr:0000000000000088 .L161
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:694    .text.read_program_from_flash_and_copy_to_ddr:000000000000013c .L162
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:688    .text.read_program_from_flash_and_copy_to_ddr:0000000000000128 .L163
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:674    .text.read_program_from_flash_and_copy_to_ddr:00000000000000f4 .L164
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:664    .text.read_program_from_flash_and_copy_to_ddr:00000000000000cc .L165
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:708    .text.read_program_from_flash_and_copy_to_ddr:000000000000016c .L171
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:698    .text.read_program_from_flash_and_copy_to_ddr:0000000000000148 .L159
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:909    .rodata.main.str1.4:0000000000000000 .LC10
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:912    .rodata.main.str1.4:0000000000000004 .LC11
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:915    .rodata.main.str1.4:0000000000000030 .LC12
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:760    .text.startup.main:00000000000000ac .L174
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:767    .text.startup.main:00000000000000c8 .L176
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:817    .text.startup.main:0000000000000150 .L177
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:810    .text.startup.main:0000000000000130 .L189
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:779    .text.startup.main:00000000000000fc .L188
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:820    .text.startup.main:000000000000015c .L180
C:\Users\i68629\AppData\Local\Temp\ccma6ONC.s:756    .text.startup.main:000000000000009c .L173

UNDEFINED SYMBOLS
FLASH_program
UART_get_rx
FLASH_init
FLASH_global_unprotect
FLASH_read_device_id
GPIO_set_output
FLASH_erase_64k_block
FLASH_read
UART_send
UART_polled_tx_string
GPIO_init
UART_init
