реклама на сайте
подробности

 
 
> Константа по фиксированному адресу. снова, STM32F4 IAR 7.5
TU-104
сообщение Aug 11 2016, 04:54
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 51
Регистрация: 10-12-08
Пользователь №: 42 354



Добрый день!
Хочу разместить прямо в код загрузчика по фиксированному адресу константу (МАК-адрес), чтобы из основной программы его считывать.

К примеру, пусть данные лежат во флешке со смещением 800

Сделал так:
Код
#pragma location = 0x08000800
  const u8 MAC_ADDR [] = {0x02, 0xAD, 0xCС, 0xСС, 0xAA, 0xBB};

И оно даже работает, НО почему то bin-файл с адреса 0x0200 до 0х0800 заполнен нулями
Соостветственно, если сделать location = 0x08000300, то нулей будет поменьше с 0х0200 до 0х0300
При этом до адреса 0200 лежат какие то ненулевые значения.
Если указать location = 0x08000200, то константа кладется как надо со смещением 200, а перед ней все равно заполняются нулями с 0x01B0 до 0x01F0.
Если кто пояснит, буду благодарен.


Еще попутно вопрос, каков размер таблицы векторов прерываний?
Приладываю файл стартапа сюда заодно
CODE
;
;
; The modules in this file are included in the libraries, and may be replaced
; by any user-defined modules that define the PUBLIC symbol _program_start or
; a user defined start symbol.
; To override the cstartup defined in the library, simply add your modified
; version to the workbench project.
;
; The vector table is normally located at address 0.
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
; The name "__vector_table" has special meaning for C-SPY:
; it is where the SP start value is found, and the NVIC vector
; table register (VTOR) is initialized to this address if != 0.
;
; Cortex-M version
;

MODULE ?cstartup

;; Forward declaration of sections.
SECTION CSTACK:DATA:NOROOT(3)

SECTION .intvec:CODE:NOROOT(2)

EXTERN __iar_program_start
EXTERN SystemInit
PUBLIC __vector_table

DATA
__vector_table
DCD sfe(CSTACK)
DCD Reset_Handler ; Reset Handler

DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler

; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI
DCD EXTI4_IRQHandler ; EXTI Line4

/// много всего получилось
...
...
DCD 0 ; Reserved
DCD DMA2D_IRQHandler ; DMA2D

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Default interrupt handlers.
;;
THUMB
PUBWEAK Reset_Handler
SECTION .text:CODE:REORDER:NOROOT(2)
Reset_Handler

LDR R0, =SystemInit
BLX R0
LDR R0, =__iar_program_start
BX R0

PUBWEAK NMI_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
NMI_Handler
B NMI_Handler
USART1_IRQHandler
B USART1_IRQHandler
...

PUBWEAK DMA2D_IRQHandler
SECTION .text:CODE:REORDER:NOROOT(1)
DMA2D_IRQHandler
B DMA2D_IRQHandler


END
/************************ © COPYRIGHT STMicroelectronics *****END OF FILE****/


и линкера
CODE
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
/*define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;*/
define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF;
define symbol __ICFEDIT_region_CCMRAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_CCMRAM_end__ = 0x1000FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_heap__ = 0x200;
/**** End of ICF editor section. ###ICF###*/
/*vlad edit*/
/*define symbol __ICFEDIT_size_MAC__ = 0x20;*/
/*vlad edit*/
/*export symbol __ICFEDIT_size_MAC__;*/


define memory mem with size = 4G;

/*vlad edit*/

/*define region MAC_region = mem:[from __ICFEDIT_region_ROM_end__-__ICFEDIT_size_MAC__+1 size __ICFEDIT_size_MAC__];*/
/*define region MAC_region = mem:[from __ICFEDIT_region_ROM_start__ size __ICFEDIT_size_MAC__];*/

/*vlad edit*/
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
/*define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];*/
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define region CCMRAM_region = mem:[from __ICFEDIT_region_CCMRAM_start__ to __ICFEDIT_region_CCMRAM_end__];

define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

initialize by copy { readwrite };
do not initialize { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
/*vlad edit*/
/*place at address mem:__ICFEDIT_region_ROM_end__-__ICFEDIT_size_MAC__+1 { readonly section .MACsection };*/
/*place in MAC_region { section .MACsection };*/

place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };


Сообщение отредактировал IgorKossak - Aug 11 2016, 09:46
Причина редактирования: [codebox] для длинного кода, [code] - для короткого!
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
ViKo
сообщение Aug 11 2016, 05:02
Сообщение #2


Универсальный солдатик
******

Группа: Модераторы
Сообщений: 8 634
Регистрация: 1-11-05
Из: Минск
Пользователь №: 10 362



Это вопрос?
Я в ST-link Utility заношу вручную нужную константу (серийный номер) в дыру между векторами прерываний.
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 21st July 2025 - 20:26
Рейтинг@Mail.ru


Страница сгенерированна за 0.01399 секунд с 7
ELECTRONIX ©2004-2016