Skip to content

CH32V003 fails to boot with non-empty BSS #616

Closed
@burgrp

Description

@burgrp

As soon as there is something in BSS section i.e. it has non-zero size, CH32V003 hangs on boot. It is caused by wrong calculation of address in the assembly code:

            \\    li a0, 0
            \\    la a1, microzig_bss_start
            \\    la a2, microzig_bss_end
            \\    beq a1, a2, clear_bss_done
            \\clear_bss_loop:
            \\    sw a0, 0(a1)
            \\    addi a1, a1, 4
            \\    blt a1, a2, clear_bss_loop
            \\clear_bss_done:

replacing la a1, microzig_bss_start with lui a1, 0x20000 "fixes" the issue.

Proper fix seems to be to link image with flash section starting at 0x instead of 0x8000000.

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