Russian Qt Forum
Января 15, 2025, 22:26
Добро пожаловать,
Гость
. Пожалуйста,
войдите
или
зарегистрируйтесь
.
Вам не пришло
письмо с кодом активации?
1 час
1 день
1 неделя
1 месяц
Навсегда
Войти
Начало
Форум
WIKI (Вики)
FAQ
Помощь
Поиск
Войти
Регистрация
Russian Qt Forum
>
Forum
>
Qt
>
Qt Embedded
>
[РЕШЕНО]Qt Creator + stm32
Страниц:
1
[
2
]
3
Вниз
« предыдущая тема
следующая тема »
Печать
Автор
Тема: [РЕШЕНО]Qt Creator + stm32 (Прочитано 34337 раз)
kuzulis
Джедай : наставник для всех
Offline
Сообщений: 2812
Re: Qt Creator + stm32
«
Ответ #15 :
Февраля 19, 2017, 16:48 »
Я представил патч для криэйтора, исправляющий запуск OpenOCD в Windows в режиме TCP/IP:
https://bugreports.qt.io/browse/QTCREATORBUG-17765
У меня вроде работает, но посмотрим что скажут.
UPD: О, и режим PIPE заработал, см. QTCREATORBUG-17765
«
Последнее редактирование: Февраля 19, 2017, 17:21 от kuzulis
»
Записан
ArchLinux x86_64 / Win10 64 bit
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #16 :
Февраля 19, 2017, 16:53 »
Спасибо большое за информацию.
Записан
GraninDm
Гость
Re: Qt Creator + stm32
«
Ответ #17 :
Февраля 21, 2017, 09:52 »
Подскажите, почему у меня такое происходит
Взял за основу проект выше
Код:
import qbs
Project {
name: "simple"
Product {
name: "micro"
type: "obj"
Group {
name: "sources"
files: ["*.c", "*.h", "*.S"]
fileTags: ['c']
}
Rule {
inputs: ["c"]
Artifact {
fileTags: ['obj']
filePath: input.fileName + '.o'
}
prepare: {
var args = [];
args.push("-g")
args.push("-Os")
args.push("-w")
args.push("-fno-exceptions")
args.push("-ffunction-sections")
args.push("-fdata-sections")
args.push("-MMD")
args.push("-mmcu=atmega328p")
args.push("-DF_CPU=16000000L")
args.push("-DARDUINO=152")
args.push("-IC:/Programs/arduino/hardware/arduino/avr/cores/arduino")
args.push("-IC:/Programs/arduino/hardware/arduino/avr/variants/standard")
args.push("-c")
args.push(input.fileName)
args.push("-o")
args.push(input.fileName + ".o")
var compilerPath = "C:/Programs/arduino/hardware/tools/avr/bin/avr-g++.exe"
var cmd = new Command(compilerPath, args);
cmd.description = 'compiling ' + input.fileName;
cmd.highlight = 'compiler';
cmd.silent = false;
return cmd;
}
}
}
}
Получаю
Код:
compiling main.c
C:/Programs/arduino/hardware/tools/avr/bin/avr-g++.exe -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD "-mmcu=atmega328p" "-DF_CPU=16000000L" "-DARDUINO=152" -IC:/Programs/arduino/hardware/arduino/avr/cores/arduino -IC:/Programs/arduino/hardware/arduino/avr/variants/standard -c main.c -o main.c.o
avr-g++.exe: main.c: No such file or directory
avr-g++.exe: no input files
Почему входных файлов нет?
Файл main.c в командную строку подставляется, в проекте присутствует, в директории проекта есть.
Что не так?
Записан
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #18 :
Февраля 21, 2017, 21:01 »
А где у Вас путь к исходникам?
Добавьте в группу prefix
Код:
Group
{
name: "sources"
prefix: "src/**/" // или где там у Вас расположены исходники
files: ["*.c", "*.h", "*.S"]
fileTags: ['c']
}
Записан
GraninDm
Гость
Re: Qt Creator + stm32
«
Ответ #19 :
Февраля 22, 2017, 09:35 »
Сегодня почему-то заработало.
Хотя ничего не менял.
Видимо, пока экспериментировал вчера у Creator текущий путь сбился.
Записан
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #20 :
Февраля 22, 2017, 13:47 »
Только объектные файлы скомпилились? Или Вы добавляли правила и на создание .elf?
Вопрос: я использую компилятор arm-none-eabi-g++ для всех файлов, все компилирутся...может это не правильно и ядро core_cm3 и system_<device> надо компилить gcc?
Записан
GraninDm
Гость
Re: Qt Creator + stm32
«
Ответ #21 :
Февраля 22, 2017, 14:59 »
Только один obj
Я посмотрел как avr собирается...
Что-то грустно стало.
Правда сейчас можно стало arduino.exe c параметрами запускать. Экзешник сам все сделает и зальет в плату если нужно.
Единственное - у меня не получилось, чтобы он консоль процесс сборки выводил.
Вроде есть парамерт --verbose-build, но он ничего в консоль не выводит.
Записан
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #22 :
Февраля 22, 2017, 20:24 »
а у меня до сих пор никак не получается сладить с линкером...кучу ошибок выдает...
Записан
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #23 :
Февраля 23, 2017, 23:11 »
Переписал все заново без использования cpp-модуля, и сделал раздельную компиляцию для исходников си, c++ и asm. Все компилится, но собрать с помощью линкера arm-none-eabi-ld, делал через arm-none-eabi-gcc...при заливке в камень, снова молчит...уже не знаю куда копать...пните пожалуйста в нужном направлении...
Код:
import qbs
Project
{
name: "stm32"
Product
{
type: ["hex", "bin"]
property string c_compilerPath: "c:/development/gcc-arm/bin/arm-none-eabi-gcc.exe"
property string cpp_compilerPath: "c:/development/gcc-arm/bin/arm-none-eabi-g++.exe"
property string asm_compilerPath: "c:/development/gcc-arm/bin/arm-none-eabi-as.exe"
property string linkerPath: "c:/development/gcc-arm/bin/arm-none-eabi-ld.exe"
property string objcpyPath: "c:/development/gcc-arm/bin/arm-none-eabi-objcopy.exe"
Group
{
name: "source_cpp"
prefix: "./"
files: ["*.cpp"]
fileTags: ["cpp"]
}
Group
{
name: "source_c"
prefix: "./"
files: ["*.c"]
fileTags: ["c"]
}
Group
{
name: "source_asm"
prefix: "./"
files: ["*.s"]
fileTags: ["asm"]
}
Rule
{
inputs: ["cpp"]
Artifact
{
filePath: project.path + "/.obj/" + input.fileName + ".o"
fileTags: ["obj"]
}
prepare:
{
var args = [];
args.push("-mcpu=cortex-m3");
args.push("-mthumb");
args.push("-O0");
args.push("--specs=nosys.specs");
args.push("-finline-functions");
args.push("-ffunction-sections");
args.push("-fdata-sections");
args.push("-fno-exceptions");
args.push("-fno-unwind-tables");
args.push("-fno-asynchronous-unwind-tables");
args.push("-c");
args.push("-DSTM32F10X_LD_VL");
args.push(project.path + "/" + input.fileName);
args.push("-o");
args.push(project.path + "/.obj/" + output.fileName);
var cmd = new Command(product.cpp_compilerPath, args);
cmd.description = "compiling: " + input.fileName;
cmd.highlight = "compiler";
cmd.silent = false;
return cmd;
}
}
Rule
{
inputs: ["c"]
Artifact
{
filePath: project.path + "/.obj/" + input.fileName + ".o"
fileTags: ["obj"]
}
prepare:
{
var args = [];
args.push("-mcpu=cortex-m3");
args.push("-mthumb");
args.push("-O0");
args.push("--specs=nosys.specs");
args.push("-finline-functions");
args.push("-ffunction-sections");
args.push("-fdata-sections");
args.push("-fno-exceptions");
args.push("-fno-unwind-tables");
args.push("-fno-asynchronous-unwind-tables");
args.push("-c");
args.push("-DSTM32F10X_LD_VL");
args.push(project.path + "/" + input.fileName);
args.push("-o");
args.push(project.path + "/.obj/" + output.fileName);
var cmd = new Command(product.c_compilerPath, args);
cmd.description = "compiling: " + input.fileName;
cmd.highlight = "compiler";
cmd.silent = false;
return cmd;
}
}
Rule
{
inputs: ["asm"]
Artifact
{
filePath: project.path + "/.obj/" + input.fileName + ".o"
fileTags: ["obj"]
}
prepare:
{
var args = [];
args.push("-mcpu=cortex-m3");
args.push("-mthumb");
args.push("-c");
args.push(project.path + "/" + input.fileName);
args.push("-o");
args.push(project.path + "/.obj/" + output.fileName);
var cmd = new Command(product.asm_compilerPath, args);
cmd.description = "compiling: " + input.fileName;
cmd.highlight = "compiler";
cmd.silent = false;
return cmd;
}
}
Rule
{
multiplex: true
inputs: ["obj"]
Artifact
{
filePath: project.path + "/bin/" + project.name + ".elf";
fileTags: ["elf"]
}
prepare:
{
var args = [];
args.push("-mcpu=cortex-m3");
args.push("-mthumb");
args.push("--specs=nosys.specs");
args.push("-finline-functions");
args.push("-ffunction-sections");
args.push("-fdata-sections");
args.push("-nostartfiles");
args.push("-fno-exceptions");
args.push("-fno-unwind-tables");
args.push("-fno-asynchronous-unwind-tables");
args.push("-T" + project.path + "/" + "stm32f10x_flash.ld");
for(i in inputs["obj"])
args.push(inputs["obj"][i].filePath);
args.push("-o");
args.push(output.filePath);
var cmd = new Command(product.c_compilerPath, args);
cmd.description = "linking project: " + project.name;
cmd.highlight = "linker";
cmd.silent = false;
return cmd;
}
}
Rule
{
inputs: ["elf"]
Artifact
{
filePath: project.path + "/bin/" + project.name + ".hex";
fileTags: ["hex"]
}
prepare:
{
var args = [];
args.push("-O");
args.push("ihex");
args.push(input.filePath);
args.push(output.filePath);
var cmd = new Command(product.objcpyPath, args);
cmd.description = "convert to hex";
cmd.highlight = "codegen";
cmd.silent = false;
return cmd;
}
}
Rule
{
inputs: ["elf"]
Artifact
{
filePath: project.path + "/bin/" + project.name + ".bin";
fileTags: ["bin"]
}
prepare:
{
var args = [];
args.push("-O");
args.push("binary");
args.push(input.filePath);
args.push(output.filePath);
var cmd = new Command(product.objcpyPath, args);
cmd.description = "convert to bin";
cmd.highlight = "codegen";
cmd.silent = false;
return cmd;
}
}
}
}
«
Последнее редактирование: Февраля 23, 2017, 23:14 от Larry
»
Записан
987654
Гость
Re: Qt Creator + stm32
«
Ответ #24 :
Февраля 26, 2017, 01:16 »
Приветствую!
Молчание камня достаточно часто происходило. Думается мне что проблема в ликере и в том что он цепляет.
У меня сейчас есть исправленный qbs ( за основу взяты проекты местных умельцев ). выходной бинарник полностью работоспособный
Вам нужно поправить мои флаги архитектуры на свои, вот на эти
Код:
FP_FLAGS
?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARCH_FLAGS
= -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
и заменить путь к скрипту, на путь к stm32f4-discovery.ld.
я так думаю что после этого должно взлететь.
Ниже то что у меня работает с stm32l152.
Комменты откуда взят флаг приложил
Код:
import qbs
import qbs.Environment
Project {
CppApplication {
Depends { name: "cpp" }
// Взято с форума
type: "bin"
name: "firmware"
property string workDirectory: Environment.getEnv("FIRMWARES_WORKDIR")
property string hexExtractor: cpp.toolchainInstallPath + "/" + cpp.toolchainPrefix + "objcopy";
cpp.cxxFlags: [ "-std=c++11",
"-msoft-float", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mthumb", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mcpu=cortex-m3", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mfix-cortex-m3-ldrd", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-extra", // главный Makefile в корне libopencm3
"-shadow", // главный Makefile в корне libopencm3
"-implicit-function-declaration", // главный Makefile в корне libopencm3
"-redundant-decls", // главный Makefile в корне libopencm3
"-missing-prototypes", // главный Makefile в корне libopencm3
"-strict-prototypes", // главный Makefile в корне libopencm3
"-fno-common", // главный Makefile в корне libopencm3
"-ffunction-sections", // главный Makefile в корне libopencm3
"-fdata-sections",] // главный Makefile в корне libopencm3
cpp.cFlags: [ "-std=gnu99",
"-msoft-float", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mthumb", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mcpu=cortex-m3", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mfix-cortex-m3-ldrd", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-extra", // главный Makefile в корне libopencm3
"-effc++", // главный Makefile в корне libopencm3
"-fno-common", // главный Makefile в корне libopencm3
"-ffunction-sections", // главный Makefile в корне libopencm3
"-fdata-sections" ] // главный Makefile в корне libopencm3
cpp.warningLevel: "all"
cpp.linkerFlags:
[
"-msoft-float", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mthumb", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mcpu=cortex-m3", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-mfix-cortex-m3-ldrd", // берется из рутовой папки примеров из ( Makefile.include ) libopencm3/examples/stm32/l1/
"-lc", // главный Makefile в корне libopencm3
"-lgcc", // главный Makefile в корне libopencm3
"-lnosys", // главный Makefile в корне libopencm3
"-static", // главный Makefile в корне libopencm3
"-nostartfiles" // главный Makefile в корне libopencm3
]
cpp.includePaths: [
"../libopencm3/libopencm3/include/",
]
cpp.libraryPaths: [
"../libopencm3/libopencm3/lib/",
]
cpp.staticLibraries: [
"opencm3_stm32l1",
"c",
"gcc",
"nosys"
]
Group {
name: "linker scripts"
files: ["../libopencm3/libopencm3/lib/stm32/l1/stm32l15xxb.ld" ] // Берется из make файла в любом живом примере из libopencm3/examples/stm32/l1/stm32l-discovery/lcd-display/
fileTags: ["linkerscript"]
}
cpp.defines: [
"STM32L1"
]
Group {
name: "src"
files: [
"src/*.c",
"src/*.cpp",
"src/*.h"
]
}
Group {
qbs.install: true
fileTagsFilter: ["application", "bin"]
}
Rule {
id: hex
inputs: ["application"]
Artifact {
fileTags: ['bin']
filePath: product.name + '.bin'
}
prepare: {
var args = [];
args.push("-j")
args.push(".text")
args.push("-j")
args.push(".data")
args.push("-O")
args.push("binary")
args.push(input.filePath);
args.push(output.filePath);
var extractorPath = product.hexExtractor;
var cmd = new Command(extractorPath, args);
return cmd;
}
}
}
}
«
Последнее редактирование: Февраля 26, 2017, 01:19 от 987654
»
Записан
alex312
Хакер
Offline
Сообщений: 606
Re: Qt Creator + stm32
«
Ответ #25 :
Февраля 26, 2017, 11:54 »
Цитата: 987654 от Февраля 26, 2017, 01:16
Приветствую!
Молчание камня достаточно часто происходило. Думается мне что проблема в ликере и в том что он цепляет.
У меня сейчас есть исправленный qbs ( за основу взяты проекты местных умельцев ). выходной бинарник полностью работоспособный
Советую обратить внимание на следующие свойства модуля cpp для уменьшения дублирования:
driverFlags
commonCompilerFlags
Пример:
Код:
...
cpp.commonCompilerFlags: ["-fdata-sections","-ffunction-sections", "-flto"]
cpp.driverFlags:["-mthumb", "-mcpu=cortex-m4","-mfloat-abi=hard","-mfpu=fpv4-sp-d16"]
Р.S.
И в опциях линкера у вас не хватает --gc-sections
«
Последнее редактирование: Февраля 26, 2017, 11:57 от alex312
»
Записан
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #26 :
Февраля 26, 2017, 14:33 »
Да, спасибо, учту. Уже все работает, затык был в линкер-скрипте...брал из разных источников
, но добрые люди подсказали, теперь компилится и работает в железе нормально. Как причешу скрипт, то здесь помещу, чтобы самому не забыть
.
Записан
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #27 :
Февраля 26, 2017, 15:05 »
А подскажите, кто знает, как в Qt creator сделать так, чтобы не было большого количества каталогов...типа такого:
\Debug\qtc_stm32f1x_02ef0d3e-debug\stm32.qtc-stm32f1x-02ef0d3e.956871f1\
Неудобно очень.
Спасибо.
Записан
987654
Гость
Re: Qt Creator + stm32
«
Ответ #28 :
Февраля 26, 2017, 20:34 »
Цитата: alex312 от Февраля 26, 2017, 11:54
...
Спасибо! qbs впервые вижу =)
Записан
Larry
Гость
Re: Qt Creator + stm32
«
Ответ #29 :
Февраля 27, 2017, 22:24 »
Как и собирался, выкладываю qbs-скрипт. Bin не генерил, только hex...и сразу заливает прошивку...Это так, чтобы самому не забыть
Единственное, что не нравится, то после прошивки выскакивает ошибка
target state: halted
, так и не понял почему...
Код:
import qbs
Product
{
type: ["application", "flash"]
Depends { name: "cpp" }
cpp.defines: ["STM32F10X_LD_VL"]
cpp.positionIndependentCode: false
cpp.enableExceptions: false
cpp.executableSuffix: ".elf"
cpp.driverFlags:
[
"-mthumb",
"-mcpu=cortex-m3",
"-mfloat-abi=soft",
"-fno-strict-aliasing",
"-g3",
"-Wall",
"-mfpu=vfp",
"-O0",
"-flto",
]
cpp.commonCompilerFlags:
[
"-fdata-sections",
"-ffunction-sections",
"-fno-inline",
"-std=c++11",
"-flto"
]
cpp.linkerFlags:
[
"--specs=nano.specs",
"-Wl,--start-group",
"-Wl,--gc-sections",
"-T" + path + "/src/system/linker/stm32f10x_flash.ld",
"-lnosys",
"-lgcc",
"-lc",
"-lstdc++",
"-lm"
]
cpp.includePaths:
[
"src/system/cmsis",
"src/system/cmsis_boot",
"src/system/cmsis_boot/statup"
]
files:
[
"src/system/cmsis/*.h",
"src/system/cmsis/*.h",
"src/system/cmsis_boot/*.h",
"src/system/cmsis_boot/*.c",
"src/system/cmsis_boot/startup/*.c",
"src/main.cpp"
]
Properties
{
condition: qbs.buildVariant === "debug"
cpp.defines: outer.concat(["DEBUG=1"])
cpp.debugInformation: true
cpp.optimization: "none"
}
Properties
{
condition: qbs.buildVariant === "release"
cpp.debugInformation: false
cpp.optimization: "small"
}
Rule
{
inputs: ["application"]
Artifact
{
filePath: project.path + "/debug/bin/" + input.baseName + ".hex"
fileTags: "flash"
}
prepare:
{
var sizePath = "c:/development/gcc-arm/bin/arm-none-eabi-size.exe";
var objcopyPath = "c:/development/gcc-arm/bin/arm-none-eabi-objcopy.exe";
var configStlinkPath = "c:/development/openocd_0_10_0/scripts/interface/stlink-v2.cfg";
var configStm32Path = "c:/development/openocd_0_10_0/scripts/target/stm32f1x.cfg";
var flashPath = "c:/development/openocd_0_10_0/bin/openocd.exe";
var argsSize = [input.filePath];
var argsObjcopy = ["-O", "ihex", input.filePath, output.filePath];
var argsFlashing =
[
"-f", configStlinkPath,
"-f", configStm32Path,
"-c", "init",
"-c", "halt",
"-c", "flash write_image erase " + input.filePath,
"-c", "reset",
"-c", "shutdown"
];
var cmdSize = new Command(sizePath, argsSize);
var cmdObjcopy = new Command(objcopyPath, argsObjcopy);
var cmdFlash = new Command(flashPath, argsFlashing);
cmdSize.description = "Size of sections:";
cmdSize.highlight = "linker";
cmdObjcopy.description = "convert to bin...";
cmdObjcopy.highlight = "linker";
cmdFlash.description = "download firmware to uC...";
cmdFlash.highlight = "linker";
return [cmdSize, cmdObjcopy, cmdFlash];
}
}
}
Записан
Страниц:
1
[
2
]
3
Вверх
Печать
« предыдущая тема
следующая тема »
Перейти в:
Пожалуйста, выберите назначение:
-----------------------------
Qt
-----------------------------
=> Вопросы новичков
=> Уроки и статьи
=> Установка, сборка, отладка, тестирование
=> Общие вопросы
=> Пользовательский интерфейс (GUI)
=> Qt Quick
=> Model-View (MV)
=> Базы данных
=> Работа с сетью
=> Многопоточное программирование, процессы
=> Мультимедиа
=> 2D и 3D графика
=> OpenGL
=> Печать
=> Интернационализация, локализация
=> QSS
=> XML
=> Qt Script, QtWebKit
=> ActiveX
=> Qt Embedded
=> Дополнительные компоненты
=> Кладовая готовых решений
=> Вклад сообщества в Qt
=> Qt-инструментарий
-----------------------------
Программирование
-----------------------------
=> Общий
=> С/C++
=> Python
=> Алгоритмы
=> Базы данных
=> Разработка игр
-----------------------------
Компиляторы и платформы
-----------------------------
=> Linux
=> Windows
=> Mac OS X
=> Компиляторы
===> Visual C++
-----------------------------
Разное
-----------------------------
=> Новости
===> Новости Qt сообщества
===> Новости IT сферы
=> Говорилка
=> Юмор
=> Объявления
Загружается...