-
Notifications
You must be signed in to change notification settings - Fork 59
Add a demo for using LVGL, DRAM, LLVM Toolchain, ELF on an STM32F746G discovery board #104
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
base: main
Are you sure you want to change the base?
Changes from all commits
d85ffbc
ba8478c
875fd98
f8d1030
8ea3fb9
86640cc
f7abba5
f011d04
c5770e0
fe246b7
cc5d739
6ccad3d
8d60315
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
./harmony/* | ||
./stm32-lcd-logo/Sources/Application/Registers/* | ||
./stm32-lvgl/Sources/Registers/* | ||
./stm32-neopixel/Sources/Application/Registers/* | ||
./stm32-uart-echo/Sources/Application/Registers/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lvgl | ||
llvm-toolchain |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"swiftPM": { | ||
"configuration": "release", | ||
"triple": "armv7em-none-none-eabi", | ||
|
||
"__comment": "XXX SourceKit-LSP seems to ignore the toolset (relative or absolute path)...", | ||
"toolset": ".../toolset.json", | ||
|
||
"swiftCompilerFlags": [ | ||
"-enable-experimental-feature", "Embedded", | ||
"-enable-experimental-feature", "Extern", | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use the format file at the repo root? |
||
"fileScopedDeclarationPrivacy" : { | ||
"accessLevel" : "private" | ||
}, | ||
"indentation" : { | ||
"spaces" : 2 | ||
}, | ||
"indentConditionalCompilationBlocks" : false, | ||
"indentSwitchCaseLabels" : false, | ||
"lineBreakAroundMultilineExpressionChainComponents" : false, | ||
"lineBreakBeforeControlFlowKeywords" : false, | ||
"lineBreakBeforeEachArgument" : false, | ||
"lineBreakBeforeEachGenericRequirement" : false, | ||
"lineLength" : 120, | ||
"maximumBlankLines" : 1, | ||
"multiElementCollectionTrailingCommas" : true, | ||
"noAssignmentInExpressions" : { | ||
"allowedFunctions" : [ | ||
"XCTAssertNoThrow" | ||
] | ||
}, | ||
"prioritizeKeepingFunctionOutputTogether" : false, | ||
"respectsExistingLineBreaks" : true, | ||
"rules" : { | ||
"AllPublicDeclarationsHaveDocumentation" : false, | ||
"AlwaysUseLiteralForEmptyCollectionInit" : true, | ||
"AlwaysUseLowerCamelCase" : false, | ||
"AmbiguousTrailingClosureOverload" : false, | ||
"BeginDocumentationCommentWithOneLineSummary" : false, | ||
"DoNotUseSemicolons" : true, | ||
"DontRepeatTypeInStaticProperties" : true, | ||
"FileScopedDeclarationPrivacy" : true, | ||
"FullyIndirectEnum" : true, | ||
"GroupNumericLiterals" : true, | ||
"IdentifiersMustBeASCII" : true, | ||
"NeverForceUnwrap" : false, | ||
"NeverUseForceTry" : true, | ||
"NeverUseImplicitlyUnwrappedOptionals" : false, | ||
"NoAccessLevelOnExtensionDeclaration" : true, | ||
"NoAssignmentInExpressions" : true, | ||
"NoBlockComments" : false, | ||
"NoCasesWithOnlyFallthrough" : true, | ||
"NoEmptyTrailingClosureParentheses" : true, | ||
"NoLabelsInCasePatterns" : true, | ||
"NoLeadingUnderscores" : false, | ||
"NoParensAroundConditions" : true, | ||
"NoPlaygroundLiterals" : true, | ||
"NoVoidReturnOnFunctionSignature" : true, | ||
"OmitExplicitReturns" : false, | ||
"OneCasePerLine" : true, | ||
"OneVariableDeclarationPerLine" : true, | ||
"OnlyOneTrailingClosureArgument" : true, | ||
"OrderedImports" : true, | ||
"ReplaceForEachWithForLoop" : true, | ||
"ReturnVoidInsteadOfEmptyTuple" : true, | ||
"TypeNamesShouldBeCapitalized" : true, | ||
"UseEarlyExits" : false, | ||
"UseExplicitNilCheckInConditions" : true, | ||
"UseLetInEveryBoundCaseVariable" : true, | ||
"UseShorthandTypeNames" : true, | ||
"UseSingleLinePropertyGetter" : true, | ||
"UseSynthesizedInitializer" : true, | ||
"UseTripleSlashForDocumentationComments" : true, | ||
"UseWhereClausesInForLoops" : false, | ||
"ValidateDocumentationComments" : true | ||
}, | ||
"spacesBeforeEndOfLineComments": 2, | ||
"spacesAroundRangeFormationOperators" : false, | ||
"tabWidth" : 2, | ||
"version" : 1 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main-snapshot-2025-03-28 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we move this to the repo root? It would be nice to have all examples on the same version. We should later update the GitHub actions to reference this file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the Swift open source project | ||
## | ||
## Copyright (c) 2023 Apple Inc. and the Swift project authors. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. date |
||
## Licensed under Apache License v2.0 with Runtime Library Exception | ||
## | ||
## See https://swift.org/LICENSE.txt for license information | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
# Paths | ||
REPOROOT := $(shell git rev-parse --show-toplevel) | ||
TOOLSROOT := $(REPOROOT)/Tools | ||
TOOLSET := $(PWD)/toolset.json | ||
ELF2HEX := $(TOOLSROOT)/elf2hex.py | ||
SWIFT_BUILD := swift build | ||
NM := nm | ||
LLVM_TOOLCHAIN := $(PWD)/llvm-toolchain | ||
|
||
# Flags | ||
ARCH := armv7em | ||
TARGET := $(ARCH)-none-none-eabi | ||
SWIFT_BUILD_ARGS := \ | ||
--configuration release \ | ||
--triple $(TARGET) \ | ||
--toolset $(TOOLSET) \ | ||
--product Application | ||
BUILDROOT := $(shell $(SWIFT_BUILD) $(SWIFT_BUILD_ARGS) --show-bin-path) | ||
|
||
.PHONY: build | ||
build: | ||
@echo "checking dependencies..." | ||
|
||
# TODO: Check that we have swiftly and recent Swift main toolchain | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm? |
||
|
||
if [[ ! -d $(PWD)/lvgl ]]; then echo "\n *** LVGL checkout not found, please run ./fetch-dependencies.sh\n" ; exit 1 ; fi | ||
if [[ ! -d $(PWD)/llvm-toolchain ]]; then echo "\n *** LLVM toolchain checkout not found, please run ./fetch-dependencies.sh\n" ; exit 1 ; fi | ||
|
||
mkdir -p .build | ||
|
||
@echo "configuring LVGL..." | ||
cmake -B .build/lvgl -G Ninja ./lvgl \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=On \ | ||
-DTOOLCHAIN_PATH=$(LLVM_TOOLCHAIN) \ | ||
-DCMAKE_TOOLCHAIN_FILE=../clang-arm-toolchain.cmake \ | ||
-DLV_CONF_PATH=../Sources/CLVGL/include/lv_conf.h | ||
|
||
@echo "building LVGL..." | ||
cmake --build .build/lvgl | ||
|
||
@echo "building..." | ||
$(SWIFT_BUILD) \ | ||
$(SWIFT_BUILD_ARGS) \ | ||
--verbose | ||
|
||
@echo "disassembling..." | ||
$(LLVM_TOOLCHAIN)/bin/llvm-objdump --all-headers --disassemble --mcpu=cortex-m7 \ | ||
$(BUILDROOT)/Application \ | ||
| c++filt | swift demangle > $(BUILDROOT)/Application.disassembly | ||
|
||
@echo "extracting binary..." | ||
$(ELF2HEX) \ | ||
$(BUILDROOT)/Application $(BUILDROOT)/Application.hex --relocate | ||
ls -al $(BUILDROOT)/Application.hex | ||
@echo "\n *** All done, build succeeded!\n" | ||
|
||
flash: | ||
@echo "flashing..." | ||
st-flash --reset --format ihex write $(BUILDROOT)/Application.hex | ||
|
||
simulator: | ||
mkdir -p .build | ||
|
||
@echo "configuring LVGL..." | ||
cmake -B .build/lvgl-host -G Ninja ./lvgl \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=On \ | ||
-DLV_CONF_PATH=../Sources/CLVGL/include/lv_conf.h | ||
|
||
@echo "building LVGL..." | ||
cmake --build .build/lvgl-host | ||
|
||
@echo "building..." | ||
$(SWIFT_BUILD) \ | ||
--configuration release \ | ||
--product HostSDLApp \ | ||
--verbose | ||
|
||
@echo "running..." | ||
$(PWD)/.build/release/HostSDLApp | ||
|
||
.PHONY: clean | ||
clean: | ||
@echo "cleaning..." | ||
@swift package clean | ||
@rm -rf .build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should make this part of matrix. instead of manually switching