Skip to content

Commit b047f4e

Browse files
authored
Merge pull request #469 from adafruit/refactor-imxrt
Refactor imxrt
2 parents bbd3e39 + 949d7ca commit b047f4e

File tree

175 files changed

+22286
-9694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+22286
-9694
lines changed

.clang-format

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: LLVM
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments:
6+
Enabled: true
7+
AcrossEmptyLines: false
8+
AcrossComments: false
9+
AlignConsecutiveBitFields:
10+
Enabled: true
11+
AcrossEmptyLines: false
12+
AcrossComments: false
13+
AlignConsecutiveDeclarations:
14+
Enabled: true
15+
AcrossEmptyLines: false
16+
AcrossComments: false
17+
AlignConsecutiveMacros:
18+
Enabled: true
19+
AcrossEmptyLines: true
20+
AcrossComments: false
21+
AlignConsecutiveShortCaseStatements:
22+
Enabled: true
23+
AcrossEmptyLines: true
24+
AcrossComments: true
25+
AlignCaseColons: false
26+
AlignEscapedNewlines: LeftWithLastLine
27+
AlignOperands: true
28+
AlignTrailingComments:
29+
Kind: Always
30+
OverEmptyLines: 2
31+
AllowAllArgumentsOnNextLine: false
32+
AllowAllConstructorInitializersOnNextLine: false
33+
AllowAllParametersOfDeclarationOnNextLine: false
34+
AllowShortBlocksOnASingleLine: Empty
35+
AllowShortCaseExpressionOnASingleLine: true
36+
AllowShortCaseLabelsOnASingleLine: false
37+
AllowShortEnumsOnASingleLine: false
38+
AllowShortFunctionsOnASingleLine: None
39+
AllowShortIfStatementsOnASingleLine: Never
40+
AlwaysBreakTemplateDeclarations: Yes
41+
BinPackArguments: true
42+
BreakBeforeBraces: Custom
43+
BraceWrapping:
44+
AfterCaseLabel: false
45+
AfterClass: false
46+
AfterControlStatement: false
47+
AfterEnum: false
48+
AfterFunction: false
49+
AfterNamespace: false
50+
AfterStruct: false
51+
AfterUnion: false
52+
AfterExternBlock: false
53+
BeforeCatch: true
54+
BeforeElse: false
55+
BeforeLambdaBody: false
56+
BeforeWhile: false
57+
SplitEmptyFunction: true
58+
SplitEmptyRecord: true
59+
SplitEmptyNamespace: true
60+
BracedInitializerIndentWidth: 2
61+
BreakBeforeBinaryOperators: None
62+
BreakConstructorInitializers: AfterColon
63+
BreakConstructorInitializersBeforeComma: false
64+
ContinuationIndentWidth: 2
65+
ColumnLimit: 120
66+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
67+
Cpp11BracedListStyle: true
68+
IncludeBlocks: Preserve
69+
IncludeCategories:
70+
- Regex: '^<.*'
71+
Priority: 1
72+
- Regex: '^".*'
73+
Priority: 2
74+
- Regex: '.*'
75+
Priority: 3
76+
IncludeIsMainRegex: '([-_](test|unittest))?$'
77+
IndentPPDirectives: BeforeHash
78+
InsertBraces: true
79+
IndentCaseLabels: true
80+
InsertNewlineAtEOF: true
81+
MacroBlockBegin: ''
82+
MacroBlockEnd: ''
83+
MaxEmptyLinesToKeep: 2
84+
NamespaceIndentation: All
85+
PenaltyBreakBeforeFirstCallParameter: 1000000
86+
PenaltyBreakOpenParenthesis: 1000000
87+
PPIndentWidth: 2
88+
QualifierAlignment: Custom
89+
QualifierOrder: ['static', 'const', 'volatile', 'restrict', 'type']
90+
SpaceAfterTemplateKeyword: false
91+
SpaceBeforeRangeBasedForLoopColon: false
92+
SpaceInEmptyParentheses: false
93+
SpacesInAngles: false
94+
SpacesInConditionalStatement: false
95+
SpacesInCStyleCastParentheses: false
96+
SpacesInParentheses: false
97+
SortIncludes: false
98+
TabWidth: 2
99+
UseTab: Never
100+
...

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ Not all features are implemented for all MCUs, following is supported MCUs and i
3838
| STM32F4 |||||| |
3939
| STM32H5 ||||| | |
4040

41+
## Supported MCUs and Boards
42+
43+
Please refer to [supported boards](./supported_boards.md) for the complete list of supported MCUs and boards.
44+
4145
## Build and Flash
4246

43-
Following is generic compiling information. Each port may require extra set-up and slight different process e.g esp32s2 require setup IDF.
47+
Following is generic compiling information. Each port may require extra set-up and slight different process e.g esp32s2
48+
require ESP-IDF.
4449

4550
### Clone
4651

apps/blinky/src/blinky.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,22 @@ int main(void) {
4141
board_timer_start(1);
4242

4343
while (1) {
44-
// nothing to do
44+
if ((_timer_count & 0xfful) == 0) {
45+
uint32_t count = _timer_count >> 8;
46+
// Toggle 2 times then pause 1
47+
if (count & 0x1ul || count & 0x4ul) {
48+
board_led_write(0x000);
49+
board_rgb_write(RGB_OFF);
50+
} else {
51+
board_led_write(0xff);
52+
board_rgb_write(RGB_WRITING);
53+
}
54+
}
4555
}
4656
}
4757

4858
void board_timer_handler(void) {
4959
_timer_count++;
50-
if ((_timer_count & 0xfful) == 0) {
51-
const uint32_t is_on = (_timer_count >> 8) & 0x1u;
52-
53-
board_led_write(is_on ? 0xff : 0x000);
54-
board_rgb_write(is_on ? RGB_WRITING : RGB_OFF);
55-
}
5660
}
5761

5862
//--------------------------------------------------------------------+

cmake/toolchain/common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if (TOOLCHAIN STREQUAL "gcc")
2525
-ffunction-sections
2626
-fsingle-precision-constant
2727
-fno-strict-aliasing
28+
-g
2829
)
2930
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
3031
-Wl,--print-memory-usage

ports/espressif/README.md

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,12 @@
1-
# TinyUF2 "Bootloader Application" for ESP32-S2 and ESP32-S3
1+
# TinyUF2 "Bootloader Application" for Espressif (S2/S3/P4)
22

33
The project is composed of customizing the 2nd stage bootloader from IDF and UF2 factory application as 3rd stage bootloader.
44

55
**Note**: IDF is actively developed and change very often, TinyUF2 is developed and tested with IDF v5.3.2. Should you have a problem please try to change your IDF version.
66

7-
Following boards are supported:
8-
9-
- [Adafruit Magtag 2.9" E-Ink WiFi Display](https://www.adafruit.com/product/4800)
10-
- [Adafruit Metro ESP32-S2](https://www.adafruit.com/product/4775)
11-
- [Deneyap Kart 1A v2](https://magaza.deneyapkart.org/tr/product/detail/deneyap-kart-1a-v2-type-c)
12-
- [Deneyap Mini](https://magaza.deneyapkart.org/tr/product/detail/deneyap-mini)
13-
- [Deneyap Mini v2](https://magaza.deneyapkart.org/tr/product/detail/deneyap-mini-v2-type-c)
14-
- [ES3ink](https://github.com/dronecz/es3ink)
15-
- [Espressif Kaluga 1](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html)
16-
- [Espressif HMI 1](https://github.com/espressif/esp-dev-kits/tree/master/esp32-s2-hmi-devkit-1)
17-
- [Espressif Saola 1R (WROVER) and 1M (WROOM)](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html)
18-
- [Gravitech Cucumber RIS ESP32-S2 w/Sensors ](https://www.gravitech.us/curisdebowis.html)
19-
- [Heltec Wireless Tracker](https://heltec.org/project/wireless-tracker)
20-
- [LILYGO® TTGO T8 ESP32-S2 V1.1](http://www.lilygo.cn/prod_view.aspx?TypeId=50063&Id=1300&FId=t3:50063:3)
21-
- [LILYGO® TTGO T8 ESP32-S2 V1.1 ST7789 ](http://www.lilygo.cn/prod_view.aspx?TypeId=50033&Id=1321&FId=t3:50033:3)
22-
- [LILYGO® TTGO T8 ESP32-S2-WROOM](http://www.lilygo.cn/prod_view.aspx?TypeId=50063&Id=1320&FId=t3:50063:3)
23-
- [LILYGO® TTGO T-Beam Supreme](https://www.lilygo.cc/products/softrf-t-beamsupreme)
24-
- [LILYGO® TTGO T-TWR Plus](https://www.lilygo.cc/products/t-twr-plus)
25-
- [LILYGO® T-Dongle S3](https://www.lilygo.cc/products/t-dongle-s3)
26-
- [LOLIN Wemos® S2 Pico](https://www.wemos.cc/en/latest/s2/s2_pico.html)
27-
- [Maker badge](https://github.com/dronecz/maker_badge)
28-
- [MicroDev microS2](https://github.com/microDev1/microS2/wiki)
29-
- [Morpheans MorphESP-240](https://github.com/ccadic/ESP32-S2-DevBoardTFT) or [MorphESP CrowdSupply](https://www.crowdsupply.com/morpheans/morphesp-240)
30-
- [Olimex ESP32S2 DevKit Lipo vB1 (WROVER and WROOM)](https://www.olimex.com/Products/IoT/ESP32-S2/ESP32-S2-DevKit-Lipo/open-source-hardware)
31-
- [Seeed XIAO ESP32S3](https://www.seeedstudio.com/XIAO-ESP32S3-p-5627.html)
32-
- [Unexpected Maker FeatherS2](https://feathers2.io)
7+
## Supported Boards
338

9+
See the board list for this family in [supported_boards.md](../../supported_boards.md#espressif).
3410

3511
## Build & Flash
3612

ports/family_support.cmake

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
3737
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
3838
endif ()
3939

40+
41+
if (NOT DEFINED JLINKEXE)
42+
if (CMAKE_HOST_WIN32)
43+
set(JLINKEXE JLink.exe)
44+
else ()
45+
set(JLINKEXE JLinkExe)
46+
endif ()
47+
endif ()
48+
49+
if (NOT DEFINED JLINK_IF)
50+
set(JLINK_IF swd)
51+
endif ()
52+
4053
#-------------------------------------------------------------
4154
# FAMILY and BOARD
4255
#-------------------------------------------------------------
@@ -150,7 +163,7 @@ function(family_configure_common TARGET)
150163
target_compile_definitions(${TARGET} PUBLIC LOGGER_${LOGGER})
151164

152165
# Add segger rtt to example
153-
if(LOGGER STREQUAL "RTT" OR LOGGER STREQUAL "rtt")
166+
if (LOGGER STREQUAL "RTT")
154167
target_sources(${TARGET} PUBLIC ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c)
155168
target_include_directories(${TARGET} PUBLIC ${TOP}/lib/SEGGER_RTT/RTT)
156169
# target_compile_definitions(${TARGET} PUBLIC SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
@@ -231,18 +244,6 @@ endfunction()
231244

232245
# Add flash jlink target, optional parameter is the extension of the binary file
233246
function(family_flash_jlink TARGET)
234-
if (NOT DEFINED JLINKEXE)
235-
if(CMAKE_HOST_WIN32)
236-
set(JLINKEXE JLink.exe)
237-
else()
238-
set(JLINKEXE JLinkExe)
239-
endif()
240-
endif ()
241-
242-
if (NOT DEFINED JLINK_IF)
243-
set(JLINK_IF swd)
244-
endif ()
245-
246247
if (NOT DEFINED JLINK_OPTION)
247248
set(JLINK_OPTION "")
248249
endif ()
@@ -281,6 +282,23 @@ exit
281282
)
282283
endfunction()
283284

285+
function(family_jlink_erase_external TARGET START_ADDR END_ADDR)
286+
file(GENERATE
287+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}-erase64k.jlink
288+
CONTENT "halt
289+
exec EnableEraseAllFlashBanks
290+
r
291+
erase ${START_ADDR} ${END_ADDR}
292+
r
293+
exit
294+
"
295+
)
296+
297+
add_custom_target(${TARGET}-erase-external-jlink
298+
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if ${JLINK_IF} -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}-erase64k.jlink
299+
)
300+
endfunction()
301+
284302

285303
# Add flash stlink target
286304
function(family_flash_stlink TARGET)

ports/make.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@ CFLAGS += \
7575
-DUF2_VERSION_BASE='"$(GIT_VERSION)"'\
7676
-DUF2_VERSION='"$(GIT_VERSION) - $(GIT_SUBMODULE_VERSIONS)"'\
7777

78-
# Bootloader src, board folder and TinyUSB stack
78+
# Bootloader src and TinyUSB stack
7979
SRC_C += \
8080
src/ghostfat.c \
8181
src/images.c \
8282
src/main.c \
8383
src/msc.c \
8484
src/screen.c \
85-
src/usb_descriptors.c \
86-
$(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_DIR)/*.c))
85+
src/usb_descriptors.c
8786

8887
endif # BUILD_APPLICATION
8988

ports/maxim/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# TinyUF2 - MAX32690 Port
2-
3-
This folder contains the port of TinyUF2 for Analog Devices' MAX32xxx/MAX78000 MCUs.
1+
# TinyUF2 for Analog Maxim
42

53
## Navigation
64

@@ -22,13 +20,15 @@ This folder contains the port of TinyUF2 for Analog Devices' MAX32xxx/MAX78000 M
2220
- [Re-Entering Bootloader Mode](#re-entering-bootloader-mode)
2321
- [Port Directory Structure](#port-directory-structure)
2422

23+
## Supported Boards
24+
25+
See the board list for this family in [supported_boards.md](../../supported_boards.md#maxim).
2526

2627
## Requirements
2728

2829
This guide focuses on building TinyUF2 for Analog Devices' MAX32 parts.
2930
It is written with Windows users in mind using the **MSDK**, but TinyUF2 is fully portable and can be built with a standard toolchain on Linux and macOS.
3031

31-
3232
### Requirements for Linux/macOS (Generic)
3333

3434
You do **not** need the MSDK to build TinyUF2 on Linux or macOS.
@@ -49,7 +49,6 @@ or
4949
python tools/get_deps.py --board apard32690
5050
```
5151

52-
5352
#### macOS Dependency Install
5453
```bash
5554
brew install arm-none-eabi-gcc make cmake git

ports/mimxrt10xx/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ family_configure_tinyuf2(tinyuf2 OPT_MCU_MIMXRT1XXX)
2525
family_flash_sdp(tinyuf2)
2626
family_flash_jlink(tinyuf2 hex)
2727

28+
# erase first 64KB to ensure clean state for UF2 update
29+
math(EXPR ERASE_END_ADDR "( ${FLASH_BASE} + 0x10000 )" OUTPUT_FORMAT HEXADECIMAL)
30+
family_jlink_erase_external(tinyuf2 ${FLASH_BASE} ${ERASE_END_ADDR})
31+
2832
# imxrt run entirely on SRAM and can update its self using uf2
29-
family_gen_uf2_from_bin(tinyuf2 ${UF2_FAMILY_ID} ${UF2_ADDR})
33+
family_gen_uf2_from_bin(tinyuf2 ${UF2_FAMILY_ID} ${FLASH_FCFB_ADDR})
3034
family_flash_uf2(tinyuf2 ${UF2_FAMILY_ID})
3135

3236
# copy to ARTIFACT_PATH

0 commit comments

Comments
 (0)