📄 start.s
字号:
b cpy_exitflash_man_ok: adr r0, int_intel_str bl print_str mov r3, #0x88000000 add r3, r3, #0x00F40000 add r3, r3, #0x00008800 add r3, r3, #0x000000F4 cmp r3, r6 beq flash_dev_ok adr r0, int_unknown2_str bl print_str mov r0, r6 bl print_hex b cpy_exitflash_dev_ok: adr r0, int_16m_b_str bl print_str /* Find the size of the data in the external flash */ mov r5, #0x020000 /* Sod it, we hardcode it to 128k */ /* Erase blocks in the internal flash, when needed */ mov r4, #0x08000000 add r6, r4, r5 mov r0, #0x00500000 add r0, r0, #0x00000050 bl data_to_flash str r0, [r4]erase_loop: /* switch to read array mode, if we're not there already */ mov r0, #0x00FF0000 add r0, r0, #0x000000FF bl data_to_flash str r0, [r4] ldr r0, [r4] cmn r0, #0x01 beq no_erase adr r0, erase_str bl print_str mov r0, r4 bl print_hex mov r0, #0x00200000 add r0, r0, #0x00000020 bl data_to_flash str r0, [r4] mov r0, #0x00D00000 add r0, r0, #0x000000D0 bl data_to_flash str r0, [r4] bl wait_status mov r3, #0x00200000 add r3, r3, #0x00000020 tst r0, r3 beq erase_ok bl print_hex adr r0, erase_err_str bl print_str b cpy_exiterase_ok: adr r0, erase_end_str bl print_strno_erase: add r4, r4, #0x04 cmp r4, r6 blt erase_loop /* Write blocks to the internal flash */ mov r4, #0x00 mov r0, #0x00500000 add r0, r0, #0x00000050 bl data_to_flash str r0, [r4] adr r0, write_start_str bl print_strwrite_loop: ldr r7, [r4] cmn r7, #0x01 beq no_write add r6, r4, #0x08000000 mov r0, #0x00400000 add r0, r0, #0x00000040 bl data_to_flash str r0, [r6] str r7, [r6] bl wait_status mov r3, #0x00100000 add r3, r3, #0x00000010 tst r0, r3 beq no_write mov r7, r0 adr r0, write_err1_str bl print_str mov r0, r7 bl print_hex adr r0, write_err2_str bl print_str mov r0, r6 bl print_hex b cpy_exitno_write: add r4, r4, #0x04 cmp r4, r5 blt write_loop /* Verify blocks written to the internal flash */ mov r4, #0x00 add r6, r4, #0x08000000 mov r0, #0x00500000 add r0, r0, #0x00000050 bl data_to_flash str r0, [r6] mov r0, #0x00FF0000 add r0, r0, #0x000000FF bl data_to_flash str r0, [r6] adr r0, vrfy_start_str bl print_strvrfy_loop: ldr r7, [r4] add r6, r4, #0x08000000 ldr r8, [r6] cmp r7, r8 beq next_vrfy adr r0, vrfy_err1_str bl print_str mov r0, r6 bl print_hex adr r0, vrfy_err2_str bl print_str mov r0, r7 bl print_hex adr r0, vrfy_err3_str bl print_str mov r0, r8 bl print_hex b cpy_exitnext_vrfy: add r4, r4, #0x04 cmp r4, r5 blt vrfy_loop adr r0, cpy_done_str bl print_strcpy_exit: b test_mem.align 4ext_flash_str: .string "Running from external flash.\n\r".align 4int_intel_str: .string "Internal flash manufacturer: Intel.\n\r".align 4int_unknown_str: .string "Error: Unknown internal flash manufacturer ID ".align 4int_16m_b_str: .string "Internal flash devices: 2 x 28F160F3 16Mbit bottom flash.\n\r".align 4int_unknown2_str: .string "Error: Unknown internal flash devices ID ".align 4erase_str: .string "Erasing block at ".align 4erase_err_str: .string " <- error !\n\r".align 4erase_end_str: .string " done.\n\r".align 4write_start_str: .string "Writing data...\n\r".align 4write_err1_str: .string "Error ".align 4write_err2_str: .string " at ".align 4vrfy_start_str: .string "Verifying data...\n\r".align 4vrfy_err1_str: .string "Verify error at address ".align 4vrfy_err2_str: .string "; expected : ".align 4vrfy_err3_str: .string "; found : ".align 4cpy_done_str: .string "Copying done.\n\r".align 4 /* Wait for the status of *both* internal flash devices to be ready. */ /* Returns the status in r0. */wait_status: mov r13, r14wait_status_loop: mov r0, #0x00700000 add r0, r0, #0x0070 bl data_to_flash mov r1, #0x08000000 str r0, [r1] ldr r0, [r1] bl data_from_flash tst r0, #0x00000080 tstne r0, #0x00800000 beq wait_status_loop mov pc, r13.globl data_to_flash.globl data_from_flash /* Subroutine that takes data in r0 and formats it so it will be in */ /* the correct order for the internal flash */data_to_flash: mov r1, #0x0 tst r0, #0x00000001 orrne r1, r1, #0x00001000 tst r0, #0x00000002 orrne r1, r1, #0x00004000 tst r0, #0x00000004 orrne r1, r1, #0x00000800 tst r0, #0x00000008 orrne r1, r1, #0x00000200 tst r0, #0x00000010 orrne r1, r1, #0x00000001 tst r0, #0x00000020 orrne r1, r1, #0x00000004 tst r0, #0x00000040 orrne r1, r1, #0x00000080 tst r0, #0x00000080 orrne r1, r1, #0x00000020 tst r0, #0x00000100 orrne r1, r1, #0x00002000 tst r0, #0x00000200 orrne r1, r1, #0x00008000 tst r0, #0x00000400 orrne r1, r1, #0x00000400 tst r0, #0x00000800 orrne r1, r1, #0x00000100 tst r0, #0x00001000 orrne r1, r1, #0x00000002 tst r0, #0x00002000 orrne r1, r1, #0x00000008 tst r0, #0x00004000 orrne r1, r1, #0x00000040 tst r0, #0x00008000 orrne r1, r1, #0x00000010 tst r0, #0x00010000 orrne r1, r1, #0x00100000 tst r0, #0x00020000 orrne r1, r1, #0x00400000 tst r0, #0x00040000 orrne r1, r1, #0x00080000 tst r0, #0x00080000 orrne r1, r1, #0x00020000 tst r0, #0x00100000 orrne r1, r1, #0x01000000 tst r0, #0x00200000 orrne r1, r1, #0x04000000 tst r0, #0x00400000 orrne r1, r1, #0x80000000 tst r0, #0x00800000 orrne r1, r1, #0x20000000 tst r0, #0x01000000 orrne r1, r1, #0x00200000 tst r0, #0x02000000 orrne r1, r1, #0x00800000 tst r0, #0x04000000 orrne r1, r1, #0x00040000 tst r0, #0x08000000 orrne r1, r1, #0x00010000 tst r0, #0x10000000 orrne r1, r1, #0x02000000 tst r0, #0x20000000 orrne r1, r1, #0x08000000 tst r0, #0x40000000 orrne r1, r1, #0x40000000 tst r0, #0x80000000 orrne r1, r1, #0x10000000 mov r0, r1 mov pc, r14 /* Takes data received from the flash, and unshuffles it. */data_from_flash: mov r1, #0x00 tst r0, #0x00000001 orrne r1, r1, #0x00000010 tst r0, #0x00000002 orrne r1, r1, #0x00001000 tst r0, #0x00000004 orrne r1, r1, #0x00000020 tst r0, #0x00000008 orrne r1, r1, #0x00002000 tst r0, #0x00000010 orrne r1, r1, #0x00008000 tst r0, #0x00000020 orrne r1, r1, #0x00000080 tst r0, #0x00000040 orrne r1, r1, #0x00004000 tst r0, #0x00000080 orrne r1, r1, #0x00000040 tst r0, #0x00000100 orrne r1, r1, #0x00000800 tst r0, #0x00000200 orrne r1, r1, #0x00000008 tst r0, #0x00000400 orrne r1, r1, #0x00000400 tst r0, #0x00000800 orrne r1, r1, #0x00000004 tst r0, #0x00001000 orrne r1, r1, #0x00000001 tst r0, #0x00002000 orrne r1, r1, #0x00000100 tst r0, #0x00004000 orrne r1, r1, #0x00000002 tst r0, #0x00008000 orrne r1, r1, #0x00000200 tst r0, #0x00010000 orrne r1, r1, #0x08000000 tst r0, #0x00020000 orrne r1, r1, #0x00080000 tst r0, #0x00040000 orrne r1, r1, #0x04000000 tst r0, #0x00080000 orrne r1, r1, #0x00040000 tst r0, #0x00100000 orrne r1, r1, #0x00010000 tst r0, #0x00200000 orrne r1, r1, #0x01000000 tst r0, #0x00400000 orrne r1, r1, #0x00020000 tst r0, #0x00800000 orrne r1, r1, #0x02000000 tst r0, #0x01000000 orrne r1, r1, #0x00100000 tst r0, #0x02000000 orrne r1, r1, #0x10000000 tst r0, #0x04000000 orrne r1, r1, #0x00200000 tst r0, #0x08000000 orrne r1, r1, #0x20000000 tst r0, #0x10000000 orrne r1, r1, #0x80000000 tst r0, #0x20000000 orrne r1, r1, #0x00800000 tst r0, #0x40000000 orrne r1, r1, #0x40000000 tst r0, #0x80000000 orrne r1, r1, #0x00400000 mov r0, r1 mov pc, r14 undefined_instruction: b undefined_instruction software_interrupt: b software_interruptabort_prefetch: b abort_prefetchabort_data: b abort_datanot_used: b not_used irq: b irqfiq: b fiq
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -