Edit online

烧写 eFuse

4 Dec 2024
Read time: 10 minute(s)

U-Boot 中烧录

在 U-Boot 中配置和使用 eFuse 驱动,可以按照以下步骤进行:
  1. 使能 eFuse 驱动

    确保在 U-Boot 的配置文件中使能 SPI_ENC 相关的 U-Boot 驱动。在 SDK 根目录中,执行 make uboot-menuconfig 命令进入配置菜单,按照如下操作进行选择:
    make uboot-menuconfig
    
    Device Drivers  --->
    Multifunction device drivers  --->
    [*] Enable Driver Model for Misc drivers
    [*] ArtInChip SID(eFuse) support
    SPL / TPL  --->
    [*] Support misc drivers

    保存并退出配置菜单,eFuse 驱动使能。

  2. 使用 eFuse 命令

    启动设备并进入 U-Boot 命令行界面,可以使用以下 eFuse 相关命令:
    U-Boot> efuse help
    "ArtInChip eFuse read/write command"    
                                
    "efuse list                             : List all banks/bits name"   
    "efuse fake     addr                    : Set RAM address as fake eFuse space for testing"
    "                                         Set to 0 to use real eFuse" 
    "efuse dump     bank offset size        : Dump data in bank"          
    "efuse read     bank offset size addr   : Read data in bank to RAM address"
    "efuse write    bank offset size addr   : Write data to bank from RAM address"
    "efuse writehex bank offset data        : Write data to bank from input hex string"
    "efuse writestr bank offset data        : Write data to bank from input string"
    "efuse dump     bitsname                : Dump data in bitsname"      
    "efuse set      bitsname value          : Set bitsname to the specific value";

    关于 eFuse 命令的详细描述,可查看eFuse 命令说明

upgcmd 命令烧录

在 bootloader 中打开 efuse 驱动后,可以在借助 upgcmd 命令烧录 efuse,upgcmd 命令在 AiBurn 的安装目录下。
  1. images 目录下得到 xx.img 文件。
  2. 在上位机中执行命令 upgcmd image xx.img
  3. Device 将运行到 U-Boot 阶段。
  4. 通过下面命令调用下位机 efuse 命令完成 efuse 读写等操作。
    • 读 efuse
      upgcmd shcmd "efuse dump psk0 0x0 0x10"
    • 写 efuse
      upgcmd shcmd "efuse writestr psk0 ArtInChip"
      upgcmd shcmd "efuse write customer 6968436E49747241"

查看 efuse 信息

upgcmd shcmd "efuse read customer 0x43000010 0 64"
upgcmd hexdump 0x43000010 64

eFuse 命令说明

  • efuse list
    U-Boot> efuse list
    bank list:
      disread			: 0x00 ~ 0x07
      diswrite			: 0x08 ~ 0x0F
      chipid_main			: 0x10 ~ 0x1F
      chipid_sub			: 0x20 ~ 0x27
      cali				: 0x28 ~ 0x2F
      brom				: 0x30 ~ 0x37
      secure			: 0x38 ~ 0x3F
      rotpk				: 0x40 ~ 0x4F
      ssk				: 0x50 ~ 0x5F
      huk				: 0x60 ~ 0x6F
      psk0				: 0x70 ~ 0x77
      psk1				: 0x78 ~ 0x7F
      psk2				: 0x80 ~ 0x87
      psk3				: 0x88 ~ 0x8F
      nvcntr			: 0x90 ~ 0x9F
      spienc_key			: 0xA0 ~ 0xAF
      spienc_nonce			: 0xB0 ~ 0xB7
      pnk				: 0xB8 ~ 0xBF
      customer			: 0xC0 ~ 0xFF
      
    bits list:
      brom.primary  : 1(NAND), 2(NOR), 3(eMMC), 4(SDCard)
      brom.secondary: 1(NAND), 2(NOR), 3(eMMC), 4(SDCard)
      brom.skip_sd_phase
      brom.checksum_dis
      brom.spi_boot_intf
      secure.jtag_lock
      secure.secure_boot_en
      secure.encrypt_boot_en
      secure.anti_rollback_en
      secure.spi_enc_en
  • efuse dump
    U-Boot> efuse dump customer 0 64
    customer:
    EE DF DF 10 BB 00 00 00 00 00 00 00 00 00 00 00 	|................|
    13 C1 00 00 00 00 00 00 01 00 0F 00 00 00 00 00 	|................|
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 	|................|
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 	|................|

    ####字符串写入

    写一串字符串到 efuse

    U-Boot> efuse writestr customer 32 ArtInChip
    U-Boot> efuse dump customer 0 64                   
    customer:
    EE DF DF 10 BB 00 00 00 00 00 00 00 00 00 00 00 	|................|
    13 C1 00 00 00 00 00 00 01 00 0F 00 00 00 00 00 	|................|
    41 72 74 49 6E 43 68 69 70 00 00 00 00 00 00 00 	|ArtInChip.......|
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 	|................|
  • 裸数据写入

    U-Boot> efuse write customer 32 6968436E49747241
    U-Boot> efuse dump customer 0 64                   
    customer:
    EE DF DF 10 BB 00 00 00 00 00 00 00 00 00 00 00 	|................|
    13 C1 00 00 00 00 00 00 01 00 0F 00 00 00 00 00 	|................|
    41 72 74 49 6E 43 68 69 70 00 00 00 00 00 00 00 	|ArtInChip.......|
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 	|................|
  • 地址写入

    先写数据到到内存中,再把内存中的数据一次写入时 eFuse efuse write bank addr offset size
    U-Boot> mw.q 0x43000000 6968436E49747241 1 
    U-Boot> md.b 0x43000000                   
    43000000: 41 72 74 49 6E 43 68 69 ff ff ff ff ff ff ff ff  ArtInChi........
    43000010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
    43000020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
    43000030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
    U-Boot> mw.q 0x43000008 0000000000000070 1
    U-Boot> md.b 0x43000000                   
    43000000: 41 72 74 49 6E 43 68 69 70 ff ff ff ff ff ff ff  ArtInChip.......
    43000010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
    43000020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
    43000030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
    U-Boot> efuse write customer 0x43000000 48 9
    U-Boot> efuse dump customer 0 64            
    customer:
    EE DF DF 10 BB 00 00 00 00 00 00 00 00 00 00 00 	|................|
    13 C1 00 00 00 00 00 00 01 00 0F 00 00 00 00 00 	|................|
    41 72 74 49 6E 43 68 69 70 00 00 00 00 00 00 00 	|ArtInChip.......|
    41 72 74 49 6E 43 68 69 70 00 00 00 00 00 00 00 	|ArtInChip.......|
  • efuse read

    读取 eFuse 数据到内存
    U-Boot> efuse read customer 0x43000010 0 64
    U-Boot> md.b 43000010
    43000010: ee df df 10 bb 00 00 00 00 00 00 00 00 00 00 00  ................
    43000020: 13 c1 00 00 00 00 00 00 01 00 0f 00 00 00 00 00  ................
    43000030: 41 72 74 49 6E 43 68 69 70 00 00 00 00 00 00 00  ArtInChip.......
    43000040: 41 72 74 49 6E 43 68 69 70 00 00 00 00 00 00 00  ArtInChip.......