This is an automated email from the ASF dual-hosted git repository. kasjer pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 6c817d7c9614d4e7fb6113f405a32a50b0db0305 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Mon Oct 19 20:57:44 2026 +0200 kernel/os/pic32: Use data-init code provided by compiler Startup code had its own copy of code that processes linker-generated .dinit table. It handles only two record formats (clear and copy) that older XC32 linkers produced. XC32 provides this code in libpic32 (__pic32_data_init) since v2.10 and Microchip startup code calls it instead. Format of the table depends on the compiler version, XC32 v5 also uses compressed records. Moreover XC32 v5 linker does not generate .dinit table at all when __pic32_data_init is not linked, so _dinit_addr was undefined. Call __pic32_data_init and link libpic32. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Jerzy Kasenberg <[email protected]> --- compiler/xc32/compiler.yml | 2 +- kernel/os/src/arch/pic32/startup/crt0.S | 50 +++++---------------------------- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/compiler/xc32/compiler.yml b/compiler/xc32/compiler.yml index 8c3d1e7ac..7406c35c9 100644 --- a/compiler/xc32/compiler.yml +++ b/compiler/xc32/compiler.yml @@ -33,6 +33,6 @@ compiler.flags.debug: [compiler.flags.base, -Og, -g3] compiler.as.flags: [-x, assembler-with-cpp, $(XC32_DFP_FLAGS)] -compiler.ld.flags: -nostartfiles -nostdlib -static-libgcc -lgcc -lm -lc-newlib -Wl,--gc-sections $(XC32_DFP_FLAGS) +compiler.ld.flags: -nostartfiles -nostdlib -static-libgcc -lgcc -lm -lc-newlib -lpic32 -Wl,--gc-sections $(XC32_DFP_FLAGS) compiler.ld.resolve_circular_deps: true compiler.ld.mapfile: true diff --git a/kernel/os/src/arch/pic32/startup/crt0.S b/kernel/os/src/arch/pic32/startup/crt0.S index 16634271d..cef74d3d4 100644 --- a/kernel/os/src/arch/pic32/startup/crt0.S +++ b/kernel/os/src/arch/pic32/startup/crt0.S @@ -273,51 +273,15 @@ _bss_check: #if defined(INIT_DATA) || defined(__PIC32_HAS_INIT_DATA) ################################################################## # Initialize data using the linker-generated .dinit table + # Format of the table depends on the compiler version, so use + # data-init code provided by the compiler (libpic32). XC32 v5 + # linker does not generate the table at all when this code is + # not linked. ################################################################## - .equiv FMT_CLEAR,0 - .equiv FMT_COPY,1 -_dinit_init: - la t0,_dinit_addr - -#define SRC t0 -#define DST t1 -#define LEN t2 -#define FMT t3 - -0: lw DST,0(SRC) - beqz DST,9f - addu SRC,4 - lw LEN,0(SRC) - addu SRC,4 - lw FMT,0(SRC) - beq FMT,$0,_dinit_clear - addu SRC,4 - -_dinit_copy: - lbu t4,0(SRC) - subu LEN,1 - addu SRC,1 - sb t4,0(DST) - bne LEN,$0,_dinit_copy - addu DST,1 - - b _dinit_end - nop - -_dinit_clear: - sb $0,(DST) - subu LEN,1 - bne LEN,$0,_dinit_clear - addu DST,1 - -_dinit_end: - addu SRC,3 - addiu LEN,$0,-4 - and SRC,LEN,SRC - lw DST,0(SRC) - bne DST,$0,0b + .extern __pic32_data_init + la t0,__pic32_data_init + jalr t0 nop -9: #endif /* INIT_DATA */
