zoukankan      html  css  js  c++  java
  • Converting flat binary into ARM ELF format

    # The part .data=0x08000000 should be replaced with the correct base offset of the ROM.
    # The value 0x08000000 is valid for STM32.
    arm-none-eabi-objcopy -I binary -O elf32-little --change-section-address .data=0x08000000 input.bin output.elf

     转换有问题,改成

    riscv64-unknown-linux-gnu-objcopy  -I binary -O elf64-little --change-section-address .data=0x08000000  fw_payload_g.bin fw_payload_g.elf

     convert the ELF file into a Bin file

     

    RISCV64-UNKNOWN-ELF cross-compilation tool for RISC-V instruction set

    The following environments are performed in the liunx ubuntu x86_64 environment, and the following examples are used to generate a 32-bit file as a target.

    screen  

    // watch IO infos  
    screen /dev/ttyACM0 115200

    compile

    riscv64-unknown-elf-gcc, RISC-V platform's riscv tool-chain.  
    // complie 64-bit file
    riscv64-unknown-elf-gcc -o file file.c
    // complie 32-bit file
    riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -o file file.c 
    process-file (32-bit platform)
    copy code
    // pretreatment
    riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -E -o file.i file.c 
    // compile
    riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -S -o file.s/file.S file.i 
    // assembler
    riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -c -o file.o file.s/file.S
    // link
    riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -o file file.o 
     
    // get ELF-file
    riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -o file file.c
    // ELF to bin
    riscv32-unknown-elf-objcopy -O binary file file.bin 
    // ELF to HEX
    riscv64-unknown-elf-objcopy -O ihex file file.hex
    
    // disassembler ELF to get ASM
    riscv64-unknown-elf-objdump -d file.elf > file.asm
    copy code
    • The ELF file is mainly a target file that is often used under x86linux.
    • BIN file is a direct binary file, there is no address tag internally
    • HEX files are often used to store programs or data transfer to ROM, EPROM, most programmers, and emulators using Intel HEX files.

    Summary: You can translate into other two files by the ELF file, and HEX can also be converted to a bin file, but BIN is to be converted to the HEX file. You must give a base address. HEX and BIN cannot be converted to an ELF file because the amount of information of ELF is large.

    upload

    upload --hex file.hex --jlink JLinkExe
  • 相关阅读:
    汇编14:端口
    汇编13:int指令
    整个软件开发的流程
    css grid 布局
    socket粘包处理
    如何做好需求变更管理?——需求变更流程规范
    软件工程需求分析文档模板
    使用layui的form.on绑定select选中事件, form.on()不执行的原因分析
    ID4收藏
    ASP.NET MVC5中View-Controller间数据的传递
  • 原文地址:https://www.cnblogs.com/dream397/p/15470410.html
Copyright © 2011-2022 走看看