From patchwork Mon Nov 30 17:55:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 106585 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.38197.1796061440679007185 for ; Mon, 30 Nov 2026 09:57:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@konsulko.com header.s=google header.b=BM/T8ri7; spf=pass (domain: konsulko.com, ip: 209.85.214.182, mailfrom: tim.orling@konsulko.com) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2f05bc71e01so45240345ad.0 for ; Mon, 30 Nov 2026 09:57:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1796061440; x=1796666240; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BZ2TthawbucbupRPhyZjhXoiASygxO3e4PDWAAmez8o=; b=BM/T8ri75AVitbL1fOpVyd0i6VsfXN1Gn10/J5ht3cBts2bFt4G+oMyMKwPbxL6hnS +FgXKBKSYAj4BfThuj/VRFYgLQb333wL0L8AF5ZEO1ta09arO/KbaGoditKkgFVvlqi4 3WyJ21rr89emiNgUycLJSae2pAxaaKeAoVfQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796061440; x=1796666240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=BZ2TthawbucbupRPhyZjhXoiASygxO3e4PDWAAmez8o=; b=DNE+bf48hlOaIA2j6BrUcDZlHalOXJaUZrHlpviPyfiZe1+JzGmnATD8O+2Dt6O5P4 Z+JZ7msf4F/tJjRNzk7+iTqdMluf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VVHhcIfOCs1 FVMLSc/9QpzdAbBfHzSUSnFWOsEPnbxltBtyBIvG0OUZq0946ynbPYc3kqyqV5p2QRg== X-Received: by 2002:a17:902:ea0c:b0:2f0:25ea:8faf with SMTP id d9443c01a7336-2f03f1b7784mr406819535ad.36.1796061440011; Mon, 30 Nov 2026 09:57:20 -0800 (PST) Return-Path: Received: from localhost (c-24-20-171-118.hsd1.or.comcast.net. [24.20.171.118]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f14fc8csm166027295ad.74.2026.11.30.09.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:57:19 -0800 (PST) From: Tim Orling To: openembedded-core@lists.openembedded.org Cc: Alejandro Hernandez , Tim Orling Subject: [PATCH v2 2/2] picolibc-helloworld: fix qemuarm hang with a virt memory layout Date: Mon, 30 Nov 2026 09:55:49 -0800 Message-ID: <20261130175714.32663-2-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130175714.32663-1-tim.orling@konsulko.com> References: <20261130175714.32663-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 17:57:30 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251641 On qemuarm the hello-world image hung without output. Upstream's hello-world/arm.ld targets Cortex-M boards with RAM at 0x20000000, but on the QEMU "virt" board used by qemuarm that address is PCIe MMIO, not RAM. The startup code faults when it copies initialized data there, and picolibc's default exception handler loops forever, so the image hangs before main(). arm.ld has had this layout since it was added upstream in 2021, so qemuarm never booted. Add a 32-bit linker script with the virt memory map (RAM at 0x40000000) and use it for qemuarm. Tested by building picolibc-helloworld for qemuarm, qemuarm64, qemuriscv32 and qemuriscv64 and running each ELF under QEMU with semihosting; all print "hello, world" and exit 0. AI-Generated: Uses Claude Code (Claude Opus 5.5) Signed-off-by: Tim Orling --- v2: add qemuarm-virt.ld to SRC_URI unconditionally (Paul Barker, RP) .../picolibc-helloworld/qemuarm-virt.ld | 18 ++++++++++++++++++ .../picolibc/picolibc-helloworld_git.bb | 13 ++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 meta/recipes-core/picolibc/picolibc-helloworld/qemuarm-virt.ld diff --git a/meta/recipes-core/picolibc/picolibc-helloworld/qemuarm-virt.ld b/meta/recipes-core/picolibc/picolibc-helloworld/qemuarm-virt.ld new file mode 100644 index 0000000000..e255c18469 --- /dev/null +++ b/meta/recipes-core/picolibc/picolibc-helloworld/qemuarm-virt.ld @@ -0,0 +1,18 @@ +/* + * Memory layout for running picolibc hello-world on the 32-bit qemuarm + * MACHINE (QEMU "virt" board, Cortex-A15). Upstream's hello-world/arm.ld + * targets Cortex-M boards (flash at 0x0, RAM at 0x20000000); on "virt" + * 0x20000000 is PCIe MMIO, so writing .data there aborts. RAM on "virt" + * starts at 0x40000000. + * + * AI-generated with Claude Code. + * + * SPDX-License-Identifier: MIT + */ +__flash = 0x40000000; +__flash_size = 0x00400000; +__ram = 0x40400000; +__ram_size = 0x00200000; +__stack_size = 8k; + +INCLUDE picolibc.ld diff --git a/meta/recipes-core/picolibc/picolibc-helloworld_git.bb b/meta/recipes-core/picolibc/picolibc-helloworld_git.bb index 573a571c24..421d3d163b 100644 --- a/meta/recipes-core/picolibc/picolibc-helloworld_git.bb +++ b/meta/recipes-core/picolibc/picolibc-helloworld_git.bb @@ -15,16 +15,19 @@ QB_OPT_APPEND:append = " -semihosting-config enable=on" # picolibc comes with a set of linker scripts, set the file # according to the architecture being built. -PICOLIBC_LINKERSCRIPT:qemuarm64 = "aarch64.ld" -PICOLIBC_LINKERSCRIPT:qemuarm = "arm.ld" -PICOLIBC_LINKERSCRIPT:qemuriscv32 = "riscv.ld" -PICOLIBC_LINKERSCRIPT:qemuriscv64 = "riscv.ld" +PICOLIBC_LINKERSCRIPT:qemuarm64 = "${S}/hello-world/aarch64.ld" +PICOLIBC_LINKERSCRIPT:qemuriscv32 = "${S}/hello-world/riscv.ld" +PICOLIBC_LINKERSCRIPT:qemuriscv64 = "${S}/hello-world/riscv.ld" +# Upstream's arm.ld is laid out for Cortex-M boards, not the QEMU "virt" +# board used by qemuarm, so use our own memory layout instead. +SRC_URI += "file://qemuarm-virt.ld" +PICOLIBC_LINKERSCRIPT:qemuarm = "${UNPACKDIR}/qemuarm-virt.ld" # Simple compile function that manually exemplifies usage; as noted, # use a custom linker script, the GCC specs provided by picolibc # and semihost to be able to test via QEMU's monitor do_compile(){ - ${CC} ${CFLAGS} ${LDFLAGS} --verbose -T${S}/hello-world/${PICOLIBC_LINKERSCRIPT} -specs=picolibc.specs --oslib=semihost -o ${BAREMETAL_BINNAME}.elf ${S}/hello-world/hello-world.c + ${CC} ${CFLAGS} ${LDFLAGS} --verbose -T${PICOLIBC_LINKERSCRIPT} -specs=picolibc.specs --oslib=semihost -o ${BAREMETAL_BINNAME}.elf ${S}/hello-world/hello-world.c ${OBJCOPY} -O binary ${BAREMETAL_BINNAME}.elf ${BAREMETAL_BINNAME}.bin }