|
1 | 1 | # stm32-lvgl
|
2 | 2 |
|
3 |
| -... |
| 3 | +<img src="assets/video.mov" /> |
| 4 | + |
| 5 | +This sample code is demonstrating a "full" graphical firmware running on an STM32 microcontroller board, concretely the STM32F746G "Discovery" board. It shows using: |
| 6 | + |
| 7 | +- **ELF file format**, linking with lld, with a custom simple linker script (and thus it builds identically on both macOS and Linux hosts) |
| 8 | +- **LLVM Embedded Toolchain for ARM** |
| 9 | +- **LVGL** graphical/input/animation library |
| 10 | +- The **DRAM, LCD, touch panel, GPIO pins and interrupts** on the STM32F746G |
| 11 | +- **No other SDKs or library dependencies** -- all the startup code, including MCU, board and peripheral initialization is done in Swift source code |
| 12 | + |
| 13 | +Additionally, this sample code: |
| 14 | + |
| 15 | +- Has **LSP integration** set up via the `.sourcekit-lsp/config.json` file, confirmed to work in multiple code editors (VS Code, Sublime Text, Zed) |
| 16 | +- Uses **SwiftPM's toolset.json** to define compiler and linker flags |
| 17 | +- Has a host OS (macOS, Linux) **"simulator" using SDL** that can use the same "business logic" code to render the same LVGL UI. |
4 | 18 |
|
5 | 19 | ## How to build and run this example:
|
6 | 20 |
|
7 |
| -... |
| 21 | +1. Connect the STM32F746G-DISCO board via the ST-LINK USB port to your Mac. |
| 22 | +2. Install a recent nightly "main" Swift toolchain. This is best done using `swiftly`, for example with: |
| 23 | +```console |
| 24 | +$ swiftly install main-snapshot-2025-04-12 |
| 25 | +$ swiftly use main-snapshot-2025-04-12 -g |
| 26 | +``` |
| 27 | +3. Install the `stlink` (https://github.com/stlink-org/stlink) command line tools, e.g. via `brew install stlink`. |
| 28 | +4. Run a provided shell script that fetches the LVGL and LLVM dependencies: |
| 29 | +```console |
| 30 | +$ ./fetch-dependencies.sh |
| 31 | +``` |
| 32 | +5. Build the firmware by running make: |
| 33 | +```console |
| 34 | +$ make |
| 35 | +``` |
| 36 | +6. Flash the built firmware by running make with the following target: |
| 37 | +```console |
| 38 | +$ make flash |
| 39 | +``` |
| 40 | + |
| 41 | +You should now see the UI animating on the board's LCD display, and the touch screen should react to inputs. |
| 42 | + |
| 43 | +Optionally, you can also run build and run the code in a desktop OS SDL "simulator" by: |
| 44 | +```console |
| 45 | +$ make simulator |
| 46 | +``` |
0 commit comments