Сб окт 23, 2021 12:05:26
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 16K
}
PROVIDE(_BLOCKSIZE = 2048);
INCLUDE stm32f01234.ld
...
.myvars :
{
. = ALIGN(_BLOCKSIZE);
__varsstart = ABSOLUTE(.);
KEEP(*(.myvars));
} > rom
extern const uint32_t _BLOCKSIZE;
extern const uint32_t __varsstart, _BLOCKSIZE;
static const uint32_t *blocksize = (uint32_t*)&_BLOCKSIZE;
static const uint32_t blocksize = (uint32_t)&_BLOCKSIZE;
Сб окт 23, 2021 19:51:03
Eddy_Em писал(а):Разобрался. Надо было вот так:
Код:
static const uint32_t blocksize = (uint32_t)&_BLOCKSIZE;
Пн окт 25, 2021 14:48:55
Пн окт 25, 2021 15:20:31
Вт окт 26, 2021 13:26:14
Вт окт 26, 2021 16:20:20
И почему если в .h-файле это "приколачивание гвоздями", то тогда в скрипте линкёра почему это не оно?
И возможен конфликт с ними.
Вт окт 26, 2021 18:14:15
Ср окт 27, 2021 03:23:27
//!Linker command file.
#define LINKER_CMD
#include "..\memmap.h"
-stack 0x00000000 //!<stack size
-heap 0x00000040 //!<heap size
SECTIONS
{
.exceptions: load = 0xFFFF0000
.bootStart: load = RAM_SDRAM_ARM_RX_BEGIN
.sysvecs > RAM_ARM, type = NOINIT
.stkSVC > RAM_ARM, type = NOINIT
.stkABT > RAM_ARM, type = NOINIT
.stkUND > RAM_ARM, type = NOINIT
.stkSYS > RAM_ARM, type = NOINIT
.stkFIQ > RAM_ARM, type = NOINIT
.stkIRQ > RAM_ARM, type = NOINIT
.stkIRQnest > RAM_ARM, type = NOINIT
.bssTrapData > RAM_ARM, type = NOINIT
.bss0: { *(.bssDMA) } > RAM_SHARED_ARM_RW, type = NOINIT
.bss > RAM_SDRAM_ARM_RW, type = NOINIT
.bssStk > RAM_SDRAM_ARM_RW, type = NOINIT
.bssInternal > RAM_SHARED_ARM_RW
.noinit > RAM_SDRAM_ARM_RW, type = NOINIT
...
Ср окт 27, 2021 08:04:21
int memoryFree()
{
int freeValue;
if((int)__brkval == 0)
freeValue = ((int)&freeValue) - ((int)&__bss_end);
else
freeValue = ((int)&freeValue) - ((int)__brkval);
return freeValue;
}
Ср окт 27, 2021 09:48:42
make
LD mk/steppers.elf
/opt/bin/arm-none-eabi-gcc --static -nostartfiles -L../inc/ld -Tstm32f072B.ld -Wl,-Map=mk/steppers.map -Wl,--gc-sections -mthumb -mcpu=cortex-m0 -march=armv6-m -mtune=cortex-m0 -msoft-float mk/adc.o mk/buttons.o mk/can.o mk/commonproto.o mk/custom_buttons.o mk/flash.o mk/hardware.o mk/main.o mk/proto.o mk/steppers.o mk/strfunct.o mk/usb.o mk/usb_lib.o mk/startup.o -Wl,--start-group -lc -lgcc -Wl,--end-group /opt/bin/../lib/gcc/arm-none-eabi/9.3.1/libgcc.a -o mk/steppers.elf
/opt/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: cannot open linker script file stm32f072xb.h: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:128: mk/steppers.elf] Error 1
stm32f030f.ld stm32f042x6.ld stm32f0728.ld stm32f103x4.ld stm32f103x8.ld stm32f103xC.ld stm32f103xE.ld stm32f103xG.ld
stm32f01234.ld stm32f042k.ld stm32f051x8.ld stm32f072B.ld stm32f103x6.ld stm32f103xB.ld stm32f103xD.ld stm32f103xF.ld
Ср окт 27, 2021 11:22:22
Eddy_Em писал(а):Dimon456, а как вы можете вообще узнать объем оперативы, если ей навстречу стек растет?
Eddy_Em писал(а):Я вообще не представляю себе, как можно программно определить предельный размер стека, чтобы наверняка не вбабахаться в него.
jcxz писал(а): И как вообще во флешь можно размещать переменные?
Ср окт 27, 2021 12:23:51
Ср окт 27, 2021 13:19:08
define symbol __region_CCM_start__ = 0x10000000;
define symbol __region_CCM_end__ = 0x1000FFFF;
define region CCM_region = mem:[from __region_CCM_start__ to __region_CCM_end__];
place in CCM_region { section .ccm };
#define CCM_RAM _Pragma("location=\".ccm\"")
CCM_RAM int32_t chData[2][AMP_BUFFERS_SIZE/2]; // Многомерный массив
CCM_RAM int32_t leftVol = 1; // Переменная
Ср окт 27, 2021 14:07:01
Eddy_Em писал(а):во флеше же только константы!
структура конфигурации меньше 50Б занимает
Что до свободной оперативки, как я понял, нужно в рантайме узнавать, сколько осталось.
А это возможно лишь с точностью до сотни-другой байт.
Ср окт 27, 2021 14:19:11
Чт окт 28, 2021 14:30:47
define region RAM_regionC = mem:[from 0x20000100 size 0x1FF00]; //DSRAM1 (ro-data)
define block IMAGE_HEAD with fixed order {section .intvec, section .checksum, section .codehead, section .intvecTail, section .codeSignature};
place in RAM_regionC {
first block IMAGE_HEAD_EXT,
section .rodata,
section .text object bsp.o,
section .text object http.o,
section .text object json.o,
section .text object japi.o,
section .text object dte.o,
last section .codetailExt
};
Чт окт 28, 2021 16:07:33
Я вам привёл фрагмент реального командного файла линкёра.
/* Linker script for STM32F030f4, 16K flash, 4K RAM. */
#include "include.h"
/* Define memory regions. */
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 16K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 4K
}
PROVIDE(_BLOCKSIZE = 1024);
/* Include the common ld script. */
INCLUDE stm32f01234.ld
#define FIRSTMACRO (1)
#define SECOND
extern int testval;
void testfunc();
make
LD mk/chiller.elf
/opt/bin/arm-none-eabi-gcc --static -nostartfiles -L../inc/ld -Tstm32f030f.ld -Wl,-Map=mk/chiller.map -Wl,--gc-sections -mthumb -mcpu=cortex-m0 -march=armv6-m -mtune=cortex-m0 -msoft-float mk/adc.o mk/hardware.o mk/main.o mk/mainloop.o mk/protocol.o mk/usart.o mk/startup.o -Wl,--start-group -lc -lgcc -Wl,--end-group /opt/bin/../lib/gcc/arm-none-eabi/9.3.1/libgcc.a -o mk/chiller.elf
/opt/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld:stm32f030f.ld:3: ignoring invalid character `#' in expression
/opt/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld:stm32f030f.ld:3: syntax error
collect2: error: ld returned 1 exit status
make: *** [Makefile:118: mk/chiller.elf] Error 1
Чт окт 28, 2021 16:34:24
Чт окт 28, 2021 16:43:03
jcxz писал(а):Или на любом LPC17xx? А то мануалы их говорят, что это невозможно.
...
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
SECTOR_0 (rx) : ORIGIN = 0x08000000, LENGTH = 16K
SECTOR_1_2 (rx) : ORIGIN = 0x08004000, LENGTH = 32K
SECTOR_3 (rx) : ORIGIN = 0x0800C000, LENGTH = 16K
SECTOR_4 (rx) : ORIGIN = 0x08010000, LENGTH = 64K
SECTOR_5_7 (rx) : ORIGIN = 0x08020000, LENGTH = 384K
}
/* Sections */
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector_FLASH :
{
. = ALIGN(4);
KEEP(*(.isr_vector_FLASH)) /* Startup code */
. = ALIGN(4);
} >SECTOR_0
.plc_params :
{
. = ALIGN(2);
KEEP (*(.plc_params))
/*. = ALIGN(2);*/
} >SECTOR_1_2
.plc_prog :
{
/*. = ALIGN(2);*/
KEEP (*(.plc_prog))
. = ALIGN(2);
} >SECTOR_1_2
.plc_D8xxx :
{
. = ALIGN(2);
KEEP (*(.plc_D8xxx))
. = ALIGN(2);
} >SECTOR_1_2
.plc_data_regs :
{
. = ALIGN(2);
KEEP (*(.plc_data_regs))
. = ALIGN(2);
} >SECTOR_3
...
...
const uint8 __PLC_params[ SIZE_BYTE_PARAMS ] \
__attribute__ ( (section( ".plc_params" ), used ) ) =
{
MAX_STEP / 1000, 0x00, // 00 0x0000 -- SIZE IN STEP 16000
0x00, 0x00, // 02 --
0x00, 0x00, // 04 --
0x00, 0x00, // 06 --
0x20, 0x20, // 08 0x0008 -- PASSWORD 0
0x20, 0x20, // 10 -- PASSWORD 1
0x20, 0x20, // 12 -- PASSWORD 2
0x20, 0x20, // 14 -- PASSWORD 3
'S', 'K', // 16 0x0010 -- PLC NAME 0
'2', 'N', // 18 -- PLC NAME 1
'-', 'F', // 20 -- PLC NAME 2
'4', '1', // 22 -- PLC NAME 3
'1', 'R', // 24 -- PLC NAME 4
'E', '-', // 26 -- PLC NAME 5
'B', 'o', // 28 -- PLC NAME 6
'k', 'r', // 30 -- PLC NAME 7
'a', 0, // 32 -- PLC NAME 8
0, 0, // 34 -- PLC NAME 9
0, 0, // 36 -- PLC NAME A
0, 0, // 38 -- PLC NAME B
0, 0, // 40 -- PLC NAME C
0, 0, // 42 -- PLC NAME D
0, 0, // 44 -- PLC NAME E
0, 0, // 46 -- PLC NAME F
...
};
const uint16 __PLC_prog[ MAX_STEP ] \
__attribute__ ( (section( ".plc_prog" ), used ) ) =
{
0x2800, 0xC801, 0x001C, // -|M0|-(M1)-
0xFFFF, // ----[FEND]-
0x000F // -----[END]-
};
const uint16 __PLC_D8XXX[ 256 ] \
__attribute__ ( (section( ".plc_D8xxx" ), used ) ) =
{
0x00C8, // D8000 - WDT 200ms
...
};
const uint16 __PLC_storredRegisters[ STORRED_REGS_NUM ] \
__attribute__ ( (section( ".plc_data_regs" ), used ) ) =
{
0
};
...
Чт окт 28, 2021 16:50:28