Skip to content

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

Merged
merged 1 commit into from
May 28, 2025

Conversation

kubamracek
Copy link
Collaborator

@kubamracek kubamracek commented Apr 10, 2025

See:

TODOs:

  • Add a README.md
  • Comment and explain the linker script and the way the relocation works
  • Sink down the ELF section section symbol start/end extraction from the Makefile into elf2hex.py
  • Add an entry with photo to the top-level README
  • Add a CI preset
  • Fix lint issues
  • Add a SDL-based simulator

@kubamracek
Copy link
Collaborator Author

Phew, the CI finally passes

@@ -42,5 +46,12 @@ jobs:
- name: Build ${{ matrix.example }}
working-directory: ${{ matrix.example }}
run: |
export STM_BOARD=STM32F746G_DISCOVERY
./build-elf.sh
if [[ "${{ matrix.example }}" == "stm32-blink" ]]; then
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about like this? (I don't immediately have an idea how to avoid the ifs completely, we do need to run different commands per example.)

      - name: Set environment variables
        run: |
          echo "STM_BOARD=STM32F746G_DISCOVERY" >> $GITHUB_ENV

      - name: Build ${{ matrix.example }}
        working-directory: ${{ matrix.example }}
        run: |
          if [[ -f ./fetch-dependencies.sh ]]; then
            ./fetch-dependencies.sh
          fi

          if [[ -f ./build-elf.sh ]]; then
            ./build-elf.sh
          fi

          if [[ -f Makefile ]]; then
            make
          fi

}
},
{
"identity" : "swiftsdl2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this avoidable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in, the whole SwiftSDL2 dependency? I'm not sure what better alternative would there be -- the only that comes to mind seems worse: To write a custom SDL Swift wrapper + also custom multiplatform makefile build steps to build SDL from its C source...

@mkbrwr
Copy link
Contributor

mkbrwr commented May 9, 2025

EDIT: fixed the problem
It's because it was dependent on compiler flag, that I've accidentally removed

Can't build the project. I get a lot of errors related to @Register macro repeated for each field

macro expansion @Register:143:30: error: property 'storage' is internal and cannot be referenced from an '@inlinable' function
`- /Users/mkbrwr/Developer/swift-embedded-examples/stm32-lvgl/Sources/Registers/FMC.swift:300:5: note: expanded code originates here
 269 |
 270 |     /// FIFO status and interrupt register
 271 |     @Register(bitWidth: 32)
     |     |- note: in expansion of macro 'Register' on struct 'SR' here
     |     `- note: in expansion of macro 'Register' on struct 'SR' here
 272 |     public struct SR {
 273 |         /// FEMPT
     :
 298 |         @ReadWrite(bits: 0..<1, as: IRSValues.self)
 299 |         public var irs: IRS
 300 |     }
     +--- macro expansion @Register ------------------------------------
     |120 | public struct Read: RegisterValueRead {
     |121 |   public typealias Value = SR
     |122 |   var storage: UInt32
     |    |       `- note: property 'storage' is not '@usableFromInline' or public
     |123 |   public init(_ value: Raw) {
     |124 |       self.storage = value.storage
     |    :
     |141 |   public var ifs: IFSValues {
     |142 |     @inlinable @inline(__always) get {
     |143 |       IFS.extract(from: self.storage)
     |    |                              `- error: property 'storage' is internal and cannot be referenced from an '@inlinable' function
     |144 |     }
     |145 |   }
     +------------------------------------------------------------------
 301 |
 302 |     /// Common memory space timing register

@kubamracek
Copy link
Collaborator Author

Can't build the project. I get a lot of errors related to @register macro repeated for each field

macro expansion @register:143:30: error: property 'storage' is internal and cannot be referenced from an '@inlinable' function
- /Users/mkbrwr/Developer/swift-embedded-examples/stm32-lvgl/Sources/Registers/FMC.swift:300:5: note: expanded code originates here 269 | 270 | /// FIFO status and interrupt register 271 | @Register(bitWidth: 32) | |- note: in expansion of macro 'Register' on struct 'SR' here | - note: in expansion of macro 'Register' on struct 'SR' here
272 | public struct SR {
273 | /// FEMPT
:
298 | @readwrite(bits: 0..<1, as: IRSValues.self)
299 | public var irs: IRS
300 | }
+--- macro expansion @register ------------------------------------
|120 | public struct Read: RegisterValueRead {
|121 | public typealias Value = SR
|122 | var storage: UInt32
| | - note: property 'storage' is not '@usableFromInline' or public |123 | public init(_ value: Raw) { |124 | self.storage = value.storage | : |141 | public var ifs: IFSValues { |142 | @inlinable @inline(__always) get { |143 | IFS.extract(from: self.storage) | | - error: property 'storage' is internal and cannot be referenced from an '@inlinable' function
|144 | }
|145 | }
+------------------------------------------------------------------
301 |
302 | /// Common memory space timing register

This has been recently fixed in swift-mmio. You might need to wipe Package.resolved to get a new "main" checkout.

@kubamracek kubamracek force-pushed the stm32-lvgl branch 2 times, most recently from 651fe01 to 8fbf045 Compare May 24, 2025 01:20
@kubamracek kubamracek requested a review from rauhul May 24, 2025 01:37
@kubamracek kubamracek merged commit b6bb69e into main May 28, 2025
21 checks passed
@kubamracek kubamracek deleted the stm32-lvgl branch May 28, 2025 17:31
@kubamracek
Copy link
Collaborator Author

Thanks everyone for reviews and feedback!

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

Successfully merging this pull request may close these issues.

5 participants