Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try swift-mmio #18

Open
kkebo opened this issue Apr 7, 2024 · 2 comments
Open

Try swift-mmio #18

kkebo opened this issue Apr 7, 2024 · 2 comments
Assignees

Comments

@kkebo
Copy link
Owner

kkebo commented Apr 7, 2024

swift-mmio might be suitable for swift_os.

However, I have not succeeded in building swift_os with swift-mmio added as an external dependency.

On the other hand, swift-embedded-examples has succeeded in doing it. I don't know what's the difference between them.

Logs:

$ swift --version
Swift version 6.0-dev (LLVM 3b959ba388a8ad9, Swift bb339b8f50f01fb)
Target: aarch64-unknown-linux-gnu
$ git diff
diff --git a/Package.swift b/Package.swift
index 9e41ccc..253a73d 100644
--- a/Package.swift
+++ b/Package.swift
@@ -7,12 +7,16 @@ let package = Package(
     products: [
         .library(name: "Kernel", type: .static, targets: ["Kernel"])
     ],
+    dependencies: [
+        .package(url: "https://github.com/apple/swift-mmio", branch: "swift-embedded-examples")
+    ],
     targets: [
         .target(
             name: "Kernel",
             dependencies: [
                 "Volatile",
                 "MailboxMessage",
+                .product(name: "MMIO", package: "swift-mmio"),
             ],
             swiftSettings: [
                 .enableExperimentalFeature("Embedded"),
$ make
clang -x assembler -target aarch64-none-none-elf -c boot.s -o boot.o
clang -x assembler -target aarch64-none-none-elf -c asmfunc.s -o asmfunc.o
swift build --triple aarch64-none-none-elf -c release
Building for production...
<unknown>:0: error: unable to load standard library for target 'aarch64-none-none-elf'
<unknown>:0: error: unable to load standard library for target 'aarch64-none-none-elf'

make: *** [Makefile:25: swift] Error 1
@kkebo kkebo self-assigned this Apr 7, 2024
@kkebo
Copy link
Owner Author

kkebo commented Apr 7, 2024

I built with --static-swift-stdlib and nothing changed.

@kkebo
Copy link
Owner Author

kkebo commented Apr 7, 2024

On Linux, stm32-uart-echo cannot be built with make too. So swift-mmio might be usable only on macOS.

$ swift --version
Swift version 6.0-dev (LLVM 3b959ba388a8ad9, Swift bb339b8f50f01fb)
Target: aarch64-unknown-linux-gnu
$ git diff
diff --git a/stm32-uart-echo/Makefile b/stm32-uart-echo/Makefile
index 5d1c929..df6269c 100755
--- a/stm32-uart-echo/Makefile
+++ b/stm32-uart-echo/Makefile
@@ -17,10 +17,10 @@ BUILDROOT := $(SRCROOT)/.build/release
 
 # Setup tools and build flags
 ARCH := armv7em
-TARGET := $(ARCH)-apple-none-macho
+TARGET := $(ARCH)-none-none-eabi
 VECTORS_ADDRESS=-0x00200000
 
-SWIFT_BUILD := $(shell xcrun -f swift-build)
+SWIFT_BUILD := swift build
 MACHO2BIN := $(SRCROOT)/../Tools/macho2bin.py
 
 .PHONY: build
diff --git a/stm32-uart-echo/Sources/Support/startup.S b/stm32-uart-echo/Sources/Support/startup.S
index 6e8c7c2..4328465 100644
--- a/stm32-uart-echo/Sources/Support/startup.S
+++ b/stm32-uart-echo/Sources/Support/startup.S
@@ -14,7 +14,6 @@
 
   .text
   .thumb
-  .section __TEXT,__text,regular,pure_instructions
   .syntax unified
 
 // reset handler, main entry point
$ make
...
<unknown>:0: error: unable to load standard library for target 'armv7em-none-none-eabi'
<unknown>:0: error: unable to load standard library for target 'armv7em-none-none-eabi'
make: *** [Makefile:29: build] Error 1

@kkebo kkebo changed the title swift-mmio Try swift-mmio Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant