Skip to content

attempts to flash hundreds of MB when ELF contains .uninit sections with LMA in RAM (e.g., from defmt-rtt) #93

@Oveln

Description

@Oveln

When flashing an ELF file that includes an uninitialized RAM section (e.g., .uninit.defmt-rtt.BUFFER from defmt-rtt), wlink incorrectly treats it as a loadable segment with physical address (LMA) in RAM (e.g., 0x20000038)

08:48:06 [DEBUG] (1) wlink::usb_device::libusb: Serial number: "E9E58F066ECA"
08:48:06 [INFO] Connected to WCH-Link v2.18(v38) (WCH-LinkE-CH32V305)
08:48:06 [INFO] Attached chip: CH32V20X [CH32V208WBU6] (ChipID: 0x2080051c)
08:48:06 [INFO] Chip ESIG: FlashSize(160KB) UID(a9-8b-d3-7b-54-50-d0-57)
08:48:06 [INFO] Flash protected: false
08:48:06 [DEBUG] (1) wlink::operations: SRAM CODE split mode: 0
08:48:06 [INFO] Read .\blinky as ELF format
08:48:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x00000000, virtual address: 0x00000000, flags: 0x5
08:48:06 [DEBUG] (1) wlink::firmware: Matching section: ".vector_table" offset: 0x1000 size: 0x1be
08:48:06 [DEBUG] (1) wlink::firmware: Matching section: ".text" offset: 0x11c0 size: 0x10b2
08:48:06 [DEBUG] (1) wlink::firmware: Section names: [".vector_table", ".text"]
08:48:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x00001274, virtual address: 0x00001274, flags: 0x4
08:48:06 [DEBUG] (1) wlink::firmware: Matching section: ".rodata" offset: 0x2274 size: 0x25c
08:48:06 [DEBUG] (1) wlink::firmware: Section names: [".rodata"]
08:48:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x000014d0, virtual address: 0x20000000, flags: 0x6
08:48:06 [DEBUG] (1) wlink::firmware: Matching section: ".data" offset: 0x3000 size: 0x38
08:48:06 [DEBUG] (1) wlink::firmware: Section names: [".data"]
08:48:06 [DEBUG] (1) wlink::firmware: Found loadable segment, physical address: 0x20000038, virtual address: 0x20000038, flags: 0x6
08:48:06 [DEBUG] (1) wlink::firmware: Matching section: ".uninit.defmt-rtt.BUFFER" offset: 0x3038 size: 0x400
08:48:06 [DEBUG] (1) wlink::firmware: Section names: [".uninit.defmt-rtt.BUFFER"]
08:48:06 [DEBUG] (1) wlink::firmware: found 4 sections
08:48:06 [DEBUG] (1) wlink::firmware: Merge firmware sections with gap: 2
08:48:06 [DEBUG] (1) wlink::firmware: Merge firmware sections with gap: 536865584
08:48:06 [INFO] Flashing 536871992 bytes to 0x08000000
08:48:06 [DEBUG] (1) wlink::operations: Reattach chip
08:48:06 [DEBUG] (1) wlink::operations: Reattach chip
08:48:06 [INFO] Read protected: false
08:48:07 [DEBUG] (1) wlink::operations: Using write pack size 4096 data pack size 256
08:48:07 [DEBUG] (1) wlink::operations: Flash OP written

this is my elf blinky
Due to some restrictions of github, please ignore the suffix of wav.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions