TRIMUI SMART

如何使用MicroSD製作多重開機模式


參考資訊:
1. Allwinner-V3s-BROM

BROM

;; Vector table
ffff0000:    ea000008     b    reset         ; reset
ffff0004:    ea000006     b    unimplemented ; _undefined_instruction
ffff0008:    ea000005     b    unimplemented ; _software_interrupt
ffff000c:    ea000004     b    unimplemented ; _prefetch_abort
ffff0010:    ea000003     b    unimplemented ; _data_abort
ffff0014:    ea000002     b    unimplemented ; _not_used
ffff0018:    ea000011     b    irq           ; _irq
ffff001c:    ea000000     b    unimplemented ; _fiq
ffff0020:    ea000013     b    fel_setup     ; FEL

unimplemented:
ffff0024:    eafffffe     b    unimplemented ; loop forever

P.S. fel = 0xffff0020

BROM

boot:
ffff2e34:    eb000cce     bl    check_uboot         ; check if uboot button is pressed, return value in r0
ffff2e38:    e1a04000     mov   r4, r0              ; r4 = check_uboot();
ffff2e3c:    e3540000     cmp   r4, #0              ; see if check_uboot returned 0
ffff2e40:    0a000000     beq   .try_boot_MMC0      ; if check_uboot was 0, try to boot from MMC0
ffff2e44:    ea000026     b     .boot_fel           ; else boot FEL mode

.try_boot_MMC0:
ffff2e48:    e3a00000     mov   r0, #0
ffff2e4c:    ebffffed     bl    0xffff2e08
ffff2e50:    e3a00000     mov   r0, #0              ; r0 = 0x0; (which card_no to boot, 0 = mmc0)
ffff2e54:    eb000190     bl    load_boot0_from_mmc ; load SPL from mmc0
ffff2e58:    e1a04000     mov   r4, r0              ; r4 = load_from_mmc();
ffff2e5c:    e3540000     cmp   r4, #0              ; see if load_from_mmc returned 0
ffff2e60:    1a000000     bne   .try_boot_eMMC      ; if load_from_mmc returned 0 try to boot from eMMc on MMC2
ffff2e64:    ea000021     b     .boot_spl           ; else skip to .boot_spl

.try_boot_eMMC:
ffff2e68:    e3a00001     mov   r0, #1
ffff2e6c:    ebffffe5     bl    0xffff2e08
ffff2e70:    e3a00002     mov   r0, #2              ; r0 = 0x2; (which card_no to boot, 2 = mmc2)
ffff2e74:    eb0001b0     bl    0xffff353c          ; load SPL from eMMC
ffff2e78:    e1a04000     mov   r4, r0              ; r4 = load_from_emmc();
ffff2e7c:    e3540000     cmp   r4, #0              ; see if load_from_emmc returned 0
ffff2e80:    1a000000     bne   .try_boot_MMC2      ; if load_from_emmc returned 0 try to boot from MMC2
ffff2e84:    ea000019     b     .boot_spl           ; else skip to .boot_spl

.try_boot_MMC2:
ffff2e88:    e3a00002     mov   r0, #2              ; r0 = 0x2; (which card_no to boot, 2 = mmc2)
ffff2e8c:    eb000182     bl    load_boot0_from_mmc ; load SPL from mmc2
ffff2e90:    e1a04000     mov   r4, r0              ; r4 = load_from_mmc();
ffff2e94:    e3540000     cmp   r4, #0              ; see if load_from_mmc returned 0
ffff2e98:    1a000000     bne   .try_boot_SPINOR; if load_from_mmc returned 0 try to boot from SPI NAND-flash
ffff2e9c:    ea000013     b     .boot_spl

.try_boot_SPINOR:
ffff2ea0:    e3a00002     mov   r0, #2
ffff2ea4:    ebffffd7     bl    0xffff2e08
ffff2ea8:    eb000c2b     bl    load_boot0_from_spinor ; load SPL from SPI NOR-flash
ffff2eac:    e1a04000     mov   r4, r0                 ; r4 = load_from_spinor();
ffff2eb0:    e3540000     cmp   r4, #0                 ; see if load_from_spinor returned 0
ffff2eb4:    1a000000     bne   .try_boot_from_SPINAND ; if load_from_spinor returned 0 try to boot from SPI NOR-flash
ffff2eb8:    ea00000c     b     .boot_spl              ; else skip to .boot_spl

.try_boot_SPINAND:
ffff2ebc:    e3a00003     mov   r0, #3
ffff2ec0:    ebffffd0     bl    0xffff2e08
ffff2ec4:    eb0000d7     bl    load_boot0_from_spinand ; load SPL from SPI NAND-flash
ffff2ec8:    e1a04000     mov   r4, r0                  ; r4 = load_from_spinand();
ffff2ecc:    e3540000     cmp   r4, #0                  ; see if load_from_spinand returned 0
ffff2ed0:    1a000000     bne   .none_found             ; if load_from_spinand returned 0 boot from FEL mode (via .none_found)
ffff2ed4:    ea000005     b     .boot_spl               ; else skip to .boot_spl

P.S. mmc2 = 0xffff2e88

main.s

    .global _start
         
    .equ GPIO_BASE, 0x01c20800
    .equ PE_CFG1,   (GPIO_BASE + (0x24 * 4) + 0x04)
    .equ PE_PULL0,  (GPIO_BASE + (0x24 * 4) + 0x1c)
    .equ PE_DATA,   (GPIO_BASE + (0x24 * 4) + 0x10)

    .arm
    .text
_start:
    .long 0xea000016
    .byte 'e', 'G', 'O', 'N', '.', 'B', 'T', '0'
    .long 0, __spl_size
    .byte 'S', 'P', 'L', 2
    .long 0, 0
    .long 0, 0, 0, 0, 0, 0, 0, 0
    .long 0, 0, 0, 0, 0, 0, 0, 0

_vector:
    b reset
    b .
    b .
    b .
    b .
    b .
    b .
    b .

reset:
    ldr r0, =PE_CFG1
    ldr r1, =0x00000000
    str r1, [r0]
     
    ldr r0, =PE_PULL0
    ldr r1, =0x55555555
    str r1, [r0]

0:
    ldr r0, =PE_DATA
    ldr r1, [r0]
    tst r1, #(1 << 12)
    beq fel
    b 0xffff2e88
fel:
    b 0xffff0020
    .end

編譯並燒錄到MicroSD後,插入開機,預設從eMMC2(官方系統)執行,如果按下SELECT按鍵開機,則進入fel模式


返回上一頁