Кто любит RISC в жизни, заходим, не стесняемся.
Ответить

Не работает прошивка после сборки с помощью qbs

Пт фев 17, 2017 14:09:22

stm32.zip
(101.69 KiB) Скачиваний: 155
Добрый день, форумчане.
Пытаюсь писать для stm32 в Qt Creator. Написал qbs-скрипт и на выходе получаю .elf. А дальше уже с помощью командной строки конвертирую в .hex через arm-none-eabi-objcpy. Сделал тестовый проект в Embitz (включение сегмента на семисегментнике), то все работает.

В Embitz получил размеры:
.elf = 397kb
.hex = 4kb

В Qt creator:
.elf = 148kb
.hex = 9kb

и после заливки ничего не работает. GDB пока не настроил, поэтому проверить не могу, где затык.
Вложил тестовый проект.

Подскажите, где я делаю не так. Спасибо.

Re: Не работает прошивка после сборки с помощью qbs

Сб фев 18, 2017 07:57:28

Скачал проект для микроконтроллеров Миландра, то все собралось без проблем...не было ошибок и предупреждений...
По тому же скрипту (там как раз cortex-m3) собираю для stm32 и получаю кучу ошибок (вчера самостоятельно писал по мануалам qbs без использования модуля срр и получал те же ошибки) ???.
Уже не знаю куда копать...перечитал уже все статьи по этой теме (у всех получается) и использую их скрипты переделанные под свою структуру проекта и постоянно, то прошивка не работает в камне, либо ошибки...

Вот qbs-скрипт (без использования модуля срр):
Код:
import qbs
Project {
    name: "simple"
    Product {
        name: "micro"
        type: "hex"
        Group {
            name: "sources"
            files: ["*.c", "*.h", "*.S"]
            fileTags: ['c']
        }
        Rule {
            inputs: ["c"]
            Artifact {
                fileTags: ['obj']
                filePath: input.fileName + '.o'
            }
            prepare: {
                var args = [];
                args.push("-mcpu=cortex-m3")
                args.push("-mthumb")
                args.push("-g")
                args.push("-ffunction-sections")
                args.push("-O0")
                args.push("-Wall")
                args.push("-Wunused")
                args.push("-DM3")
                args.push('-c');
                args.push(input.filePath);
                args.push('-o');
                args.push(output.filePath);
                var compilerPath = "c:/development/gcc-arm/bin/arm-none-eabi-gcc.exe"
                var cmd = new Command(compilerPath, args);
                cmd.description = 'compiling ' + input.fileName;
                cmd.highlight = 'compiler';
                cmd.silent = false;
                return cmd;
            }
        }
        Rule{
            multiplex: true
            inputs: ['obj']
            Artifact{
                fileTags:['elf']
                filePath: project.name + '.elf'
            }
            prepare:{
                var args = []
                args.push("-mcpu=cortex-m3")
                args.push("-mthumb")
                args.push("-g")
                args.push("-nostartfiles")
                args.push("-O0")
                args.push("-Wl,--gc-sections")
                for(i in inputs['obj'])
                    args.push(inputs["obj"][i].filePath);
                args.push("-Td:/work/workspace/uc/qbs_c/stm32f10x_flash.ld")
                args.push('-o');
                args.push(output.filePath);
                var compilerPath = "c:/development/gcc-arm/bin/arm-none-eabi-gcc.exe"
                var cmd = new Command(compilerPath,args);
                cmd.description = "linking"+project.name
                return cmd;
            }
        }
        Rule{
            inputs: ['elf']
            Artifact{
                fileTags:['hex']
                filePath: project.name + '.hex'
            }
            prepare:{
                var args = []
                args.push("-O")
                args.push("ihex")
                args.push(input.filePath)
                args.push(output.filePath)
                var hexcreator = "c:/development/gcc-arm/bin/arm-none-eabi-objcopy.exe"
                var cmd = new Command(hexcreator,args);
                cmd.description = 'create_hex'+project.name
                return cmd;
            }
        }
    }
}


Ошибки которые вылазят:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)

error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)

error: unknown type name '__STATIC_INLINE'
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)

и в том же роде

Re: Не работает прошивка после сборки с помощью qbs

Сб фев 18, 2017 17:29:52

В Вашем архиве то на что ругается объявлено вот так
static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); }

это эначит что h файлы откуда то берутся из другого места.
Попробуйте добавить явно -I опции для нужных каталогов.

кроме того можно самому набрать командную строку и поиграться

Re: Не работает прошивка после сборки с помощью qbs

Сб фев 18, 2017 18:49:47

Спасибо, попробую, т.к. я понимаю, что где-то траблы с подключением хедеров. Сейчас читаю мануалы по qbs внимательно, посмотрю, может что и вычитаю :)

Re: Не работает прошивка после сборки с помощью qbs

Чт фев 23, 2017 22:05:04

Переписал все заново без использования 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;
            }
        }
    }
}

Re: Не работает прошивка после сборки с помощью qbs

Пт фев 24, 2017 08:38:58

предложу такой вариант
В рабочем проекте Embitz можно подсмотреть все опции компилятора и линкера, немножко через заднее крыльцо:
в настройках:
Изображение
посмотреть:
Изображение
и сравнить со своими.
з.ы. у Микрософта сейчас появился вполне неплохой редактор VS Code - в нем можно делать сборку, в принципе с любой системой сборки, и даже народ GDB отладку Армов прикручивает

Re: Не работает прошивка после сборки с помощью qbs

Пт фев 24, 2017 12:05:15

Спасибо большое. Посмотрю, где я туплю...
Ответить