Skip to content

Commit

Permalink
🔨 INI cleanup and updates
Browse files Browse the repository at this point in the history
Co-Authored-By: Martin Turski <turningtides@outlook.de>
  • Loading branch information
thinkyhead and quiret committed Mar 25, 2023
1 parent d288a68 commit eaf80fa
Show file tree
Hide file tree
Showing 19 changed files with 231 additions and 279 deletions.
6 changes: 3 additions & 3 deletions Marlin/src/HAL/STM32/tft/tft_fsmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void TFT_FSMC::Init() {
Timing.DataLatency = 17;
Timing.AccessMode = FSMC_ACCESS_MODE_A;
// Write Timing
// Can be decreases from 8-15-8 to 0-0-1 with risk of stability loss
// Can be decreased from 8-15-8 to 0-0-1 with risk of stability loss
ExtTiming.AddressSetupTime = 8;
ExtTiming.AddressHoldTime = 15;
ExtTiming.DataSetupTime = 8;
Expand Down Expand Up @@ -170,13 +170,13 @@ void TFT_FSMC::Abort() {
HAL_DMA_DeInit(&DMAtx); // Deconfigure DMA
}

void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count) {
DMAtx.Init.PeriphInc = MemoryIncrease;
HAL_DMA_Init(&DMAtx);
HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(LCD->RAM), Count);
}

void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
void TFT_FSMC::Transmit(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count) {
DMAtx.Init.PeriphInc = MemoryIncrease;
HAL_DMA_Init(&DMAtx);
DataTransferBegin();
Expand Down
16 changes: 10 additions & 6 deletions Marlin/src/HAL/STM32/tft/tft_fsmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#error "FSMC TFT is currently only supported on STM32F1 and STM32F4 hardware."
#endif

#ifndef HAL_SRAM_MODULE_ENABLED
#error "SRAM module disabled for the STM32 framework (HAL_SRAM_MODULE_ENABLED)! Please consult the development team."
#endif

#ifndef LCD_READ_ID
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
#endif
Expand Down Expand Up @@ -60,28 +64,28 @@ class TFT_FSMC {

static uint32_t ReadID(tft_data_t Reg);
static void Transmit(tft_data_t Data) { LCD->RAM = Data; __DSB(); }
static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
static void Transmit(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count);
static void TransmitDMA(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count);

public:
static void Init();
static uint32_t GetID();
static bool isBusy();
static void Abort();

static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {}
static void DataTransferBegin() {}
static void DataTransferEnd() {};

static void WriteData(uint16_t Data) { Transmit(tft_data_t(Data)); }
static void WriteReg(uint16_t Reg) { LCD->REG = tft_data_t(Reg); __DSB(); }

static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
static void WriteSequence_DMA(const uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }

static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); }
static void WriteSequence(const uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple(uint16_t Color, uint32_t Count) {
while (Count > 0) {
Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count);
Transmit(DMA_PINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count);
Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0;
}
}
Expand Down
9 changes: 7 additions & 2 deletions Marlin/src/HAL/STM32F1/sdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) {
}

bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
uint32_t retries = SDIO_READ_RETRIES;
while (retries--) if (SDIO_ReadBlock_DMA(blockAddress, data)) return true;
uint8_t retries = SDIO_READ_RETRIES;
while (retries--) {
if (SDIO_ReadBlock_DMA(blockAddress, data)) return true;
#if SD_RETRY_DELAY_MS
delay(SD_RETRY_DELAY_MS);
#endif
}
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "../../../inc/MarlinConfig.h"

#if HAS_FSMC_TFT
#if HAS_FSMC_TFT && ENABLED(MAPLE_STM32F1)

#include "tft_fsmc.h"
#include <libmaple/fsmc.h>
Expand Down Expand Up @@ -239,15 +239,15 @@ void TFT_FSMC::Abort() {
channel_regs->CPAR = 0U;
}

void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count) {
// TODO: HAL STM32 uses DMA2_Channel1 for FSMC on STM32F1
dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease);
dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count);
dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
}

void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
void TFT_FSMC::Transmit(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count) {
#if defined(FSMC_DMA_DEV) && defined(FSMC_DMA_CHANNEL)
dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease);
dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count);
Expand All @@ -259,4 +259,4 @@ void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count)
#endif
}

#endif // HAS_FSMC_TFT
#endif // HAS_FSMC_TFT && MAPLE_STM32F1
8 changes: 4 additions & 4 deletions Marlin/src/HAL/STM32F1/tft/tft_fsmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class TFT_FSMC {

static uint32_t ReadID(uint16_t Reg);
static void Transmit(uint16_t Data);
static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
static void Transmit(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count);
static void TransmitDMA(uint32_t MemoryIncrease, const uint16_t *Data, uint16_t Count);

public:
static void Init();
Expand All @@ -64,10 +64,10 @@ class TFT_FSMC {
static void WriteData(uint16_t Data) { Transmit(Data); }
static void WriteReg(uint16_t Reg);

static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
static void WriteSequence_DMA(const uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }

static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); }
static void WriteSequence(const uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple(uint16_t Color, uint32_t Count) {
while (Count > 0) {
Transmit(DMA_PINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count);
Expand Down
8 changes: 7 additions & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include "HAL/shared/esp_wifi.h"
#include "HAL/shared/cpu_exception/exception_hook.h"

#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
#include "HAL/shared/esp_wifi.h"
#endif

#ifdef ARDUINO
#include <pins_arduino.h>
#endif
Expand Down Expand Up @@ -1270,7 +1274,9 @@ void setup() {

SETUP_RUN(hal.init_board());

SETUP_RUN(esp_wifi_init());
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
SETUP_RUN(esp_wifi_init());
#endif

// Report Reset Reason
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/feature/mmu/mmu2-serial-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,3 @@ Eject filament

- MMU <= 'E*Filament index*\n'
- MMU => 'ok\n'

1 change: 0 additions & 1 deletion Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
}
}


#endif // TOOL_SENSOR

#if ENABLED(SWITCHING_TOOLHEAD)
Expand Down
11 changes: 11 additions & 0 deletions buildroot/share/PlatformIO/scripts/common-dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,14 @@
#define HAS_MENU_UBL
#endif
#endif

#define HELVETICA 1
#define NOTOSANS 2
#define UNIFONT 3
#if TFT_FONT == HELVETICA
#define TFT_FONT_HELVETICA
#elif TFT_FONT == NOTOSANS
#define TFT_FONT_NOTOSANS
#elif TFT_FONT == UNIFONT
#define TFT_FONT_UNIFONT
#endif
98 changes: 86 additions & 12 deletions buildroot/share/PlatformIO/scripts/common-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import pioutil
if pioutil.is_pio_build():

import subprocess,os,re
import subprocess,os,re,fnmatch,glob
srcfilepattern = re.compile(r".*[.](cpp|c)$")
marlinbasedir = os.path.join(os.getcwd(), "Marlin/")
Import("env")

from platformio.package.meta import PackageSpec
Expand Down Expand Up @@ -128,6 +130,7 @@ def force_ignore_unused_libs():
def apply_features_config():
load_features()
blab("========== Apply enabled features...")
build_filters = ' '.join(env.GetProjectOption('src_filter'))
for feature in FEATURE_CONFIG:
if not env.MarlinHas(feature):
continue
Expand Down Expand Up @@ -174,23 +177,92 @@ def apply_features_config():

if 'src_filter' in feat:
blab("========== Adding build_src_filter for %s... " % feature, 2)
src_filter = ' '.join(env.GetProjectOption('src_filter'))
# first we need to remove the references to the same folder
my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter'])
cur_srcs = re.findall(r'[+-](<.*?>)', src_filter)
for d in my_srcs:
if d in cur_srcs:
src_filter = re.sub(r'[+-]' + d, '', src_filter)

src_filter = feat['src_filter'] + ' ' + src_filter
set_env_field('build_src_filter', [src_filter])
env.Replace(SRC_FILTER=src_filter)
build_filters = build_filters + ' ' + feat['src_filter']
# Just append the filter in the order that the build environment specifies.
# Important here is the order of entries in the "features.ini" file.

if 'lib_ignore' in feat:
blab("========== Adding lib_ignore for %s... " % feature, 2)
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
set_env_field('lib_ignore', lib_ignore)

src_filter = ""
if True:
# Build the actual equivalent build_src_filter list based on features.
cur_srcs = set()
# first we need to remove the references to the same folder
my_srcs = re.findall(r'([+-]<.*?>)', build_filters)

for d in my_srcs:
# gonna assume normalized relative paths here.
plain = d[2:-1]
if d[0] == '+':
def addentry(fullpath, info=None):
relp = os.path.relpath(fullpath, marlinbasedir)
if srcfilepattern.match(relp):
if info:
blab("Added src file " + relp + " (" + str(info) + ")")
else:
blab("Added src file " + relp)
cur_srcs.add(relp)
# Special rule by PlatformIO: if a direct folder is specified then add all files
# inside of that folder
fullplain = os.path.join(marlinbasedir, plain)
if os.path.isdir(fullplain):
blab( "Directory content addition for " + plain )
gpattern = os.path.join(fullplain, "**")
for fname in glob.glob(gpattern, recursive=True):
addentry(fname, "dca")
else:
# Add all the things from the pattern by GLOB.
def srepl(matchi):
g0 = matchi.group(0)
return r"**" + g0[1:]
gpattern = re.sub(r'[*]($|[^*])', srepl, plain)
gpattern = os.path.join(marlinbasedir, gpattern)

for fname in glob.glob(gpattern, recursive=True):
addentry(fname)
else:
# Special rule by PlatformIO: if a direct folder is specified then remove all files
# from it.
def onremove(relp, info=None):
if info:
blab("Removed src file " + relp + " (" + str(info) + ")")
else:
blab("Removed src file " + relp)
fullplain = os.path.join(marlinbasedir, plain)
if os.path.isdir(fullplain):
blab("Directory content removal for " + plain)
def filt(x):
common = os.path.commonpath([plain, x])
if not common == os.path.normpath(plain):
return True
onremove(x, "dcr")
return False
cur_srcs = set(filter(filt, cur_srcs))
else:
# Remove source entries that match pattern.
def filt(x):
if not fnmatch.fnmatch(x, plain):
return True
onremove(x)
return False
cur_srcs = set(filter(filt, cur_srcs))
# Transform the set into a string.
for x in cur_srcs:
if len(src_filter) > 0:
src_filter += ' '
src_filter += "+<" + x + ">"

#print( "Final: " + src_filter )
else:
src_filter = build_filters

# Tell it to PlatformIO.
set_env_field('build_src_filter', [src_filter])
env.Replace(SRC_FILTER=src_filter)

#
# Use the compiler to get a list of all enabled features
#
Expand Down Expand Up @@ -226,6 +298,8 @@ def MarlinHas(env, feature):
elif val in env['MARLIN_FEATURES']:
some_on = env.MarlinHas(val)

#print( feature + " is " + str(some_on) )

return some_on

validate_pio()
Expand Down
29 changes: 18 additions & 11 deletions buildroot/share/PlatformIO/scripts/generic_create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# will be picked up by PlatformIO just like any other variant.
#
import pioutil
import re
marlin_variant_pattern = re.compile("marlin_.*")
if pioutil.is_pio_build():
import shutil,marlin
from pathlib import Path
Expand All @@ -32,7 +34,7 @@
else:
platform_name = PackageSpec(platform_packages[0]).name

if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]:
if platform_name in [ "Arduino_Core_STM32", "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]:
platform_name = "framework-arduinoststm32"

FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name))
Expand All @@ -44,15 +46,20 @@
variant = board.get("build.variant")
#series = mcu_type[:7].upper() + "xx"

# Prepare a new empty folder at the destination
variant_dir = FRAMEWORK_DIR / "variants" / variant
if variant_dir.is_dir():
shutil.rmtree(variant_dir)
if not variant_dir.is_dir():
variant_dir.mkdir()
# Only prepare a new variant if the env has board_build.variant).
# This prevents deleting any official board config variants.
if marlin_variant_pattern.match(str(variant).lower()):
# Prepare a new empty folder at the destination
variant_dir = FRAMEWORK_DIR / "variants" / variant
if variant_dir.is_dir():
shutil.rmtree(variant_dir)
if not variant_dir.is_dir():
variant_dir.mkdir()

# Source dir is a local variant sub-folder
source_dir = Path("buildroot/share/PlatformIO/variants", variant)
assert source_dir.is_dir()
# Source dir is a local variant sub-folder
source_dir = Path("buildroot/share/PlatformIO/variants", variant)
assert source_dir.is_dir()

marlin.copytree(source_dir, variant_dir)
print("Copying variant " + str(variant) + " to framework directory...")

marlin.copytree(source_dir, variant_dir)
Loading

0 comments on commit eaf80fa

Please sign in to comment.