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

 
 
3 страниц V   1 2 3 >  
Reply to this topicStart new topic
> ARM startup code
doom13
сообщение Nov 4 2017, 14:38
Сообщение #1


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



Приветствую.
Исходные данные:
1) LPC1766
2) ARM DS-5
3) CMSIS Packs Plug-in
4) GNU ARM OpenOCD
Проблема - при старте программы не происходит инициализация глобальных переменных. Как понимаю, надо добавить кусок кода (что-то типа __initialize_data и __initialize_bss) в startup.s + подправить scatter-file (пока используются стандартные для нового проекта)??? Аналогичный вопрос, но без ответа.

Код
; *************************************************************
; ** Scatter-Loading Description File generated by RTE CMSIS Plug-in **
; *************************************************************
LR_IROM1 0x00000000 0x40000 {  ; load region size_region
  ER_IROM1 0x00000000 0x40000 {; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_IRAM1 0x10000000 0x8000 {
   *.o (.bss)
  }
  RW_IRAM2 0x2007C000 0x8000 {
   .ANY (+RW +ZI)
  }
}


CODE

;/**************************************************************************//**
; * @file startup_LPC17xx.s
; * @brief CMSIS Cortex-M3 Core Device Startup File for
; * NXP LPC17xx Device Series
; * @version V1.10
; * @date 06. April 2011
; *
; * @note
; * Copyright © 2009-2011 ARM Limited. All rights reserved.
; *
; * @par
; * ARM Limited (ARM) is supplying this software for use with Cortex-M
; * processor based microcontrollers. This file can be freely distributed
; * within development tools that are supporting such ARM based processors.
; *
; * @par
; * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
; * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
; * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
; * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
; * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
; *
; ******************************************************************************/

; *------- <<< Use Configuration Wizard in Context Menu >>> ------------------

; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Stack_Size EQU 0x00002000

AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp


; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Heap_Size EQU 0x00002000

AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit


PRESERVE8
THUMB


; Vector Table Mapped to Address 0 at Reset

AREA RESET, DATA, READONLY
EXPORT __Vectors

__Vectors DCD __initial_sp ; Top of Stack
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 WDT_IRQHandler ; 16: Watchdog Timer
DCD TIMER0_IRQHandler ; 17: Timer0
DCD TIMER1_IRQHandler ; 18: Timer1
DCD TIMER2_IRQHandler ; 19: Timer2
DCD TIMER3_IRQHandler ; 20: Timer3
DCD UART0_IRQHandler ; 21: UART0
DCD UART1_IRQHandler ; 22: UART1
DCD UART2_IRQHandler ; 23: UART2
DCD UART3_IRQHandler ; 24: UART3
DCD PWM1_IRQHandler ; 25: PWM1
DCD I2C0_IRQHandler ; 26: I2C0
DCD I2C1_IRQHandler ; 27: I2C1
DCD I2C2_IRQHandler ; 28: I2C2
DCD SPI_IRQHandler ; 29: SPI
DCD SSP0_IRQHandler ; 30: SSP0
DCD SSP1_IRQHandler ; 31: SSP1
DCD PLL0_IRQHandler ; 32: PLL0 Lock (Main PLL)
DCD RTC_IRQHandler ; 33: Real Time Clock
DCD EINT0_IRQHandler ; 34: External Interrupt 0
DCD EINT1_IRQHandler ; 35: External Interrupt 1
DCD EINT2_IRQHandler ; 36: External Interrupt 2
DCD EINT3_IRQHandler ; 37: External Interrupt 3
DCD ADC_IRQHandler ; 38: A/D Converter
DCD BOD_IRQHandler ; 39: Brown-Out Detect
DCD USB_IRQHandler ; 40: USB
DCD CAN_IRQHandler ; 41: CAN
DCD DMA_IRQHandler ; 42: General Purpose DMA
DCD I2S_IRQHandler ; 43: I2S
DCD ENET_IRQHandler ; 44: Ethernet
DCD RIT_IRQHandler ; 45: Repetitive Interrupt Timer
DCD MCPWM_IRQHandler ; 46: Motor Control PWM
DCD QEI_IRQHandler ; 47: Quadrature Encoder Interface
DCD PLL1_IRQHandler ; 48: PLL1 Lock (USB PLL)
DCD USBActivity_IRQHandler ; 49: USB Activity interrupt to wakeup
DCD CANActivity_IRQHandler ; 50: CAN Activity interrupt to wakeup


IF :LNOT::DEF:NO_CRP
AREA |.ARM.__at_0x02FC|, CODE, READONLY
CRP_Key DCD 0xFFFFFFFF
ENDIF


AREA |.text|, CODE, READONLY

; Reset Handler

Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main

LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP


; Dummy Exception Handlers (infinite loops which can be modified)

NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP

Default_Handler PROC

EXPORT WDT_IRQHandler [WEAK]
EXPORT TIMER0_IRQHandler [WEAK]
EXPORT TIMER1_IRQHandler [WEAK]
EXPORT TIMER2_IRQHandler [WEAK]
EXPORT TIMER3_IRQHandler [WEAK]
EXPORT UART0_IRQHandler [WEAK]
EXPORT UART1_IRQHandler [WEAK]
EXPORT UART2_IRQHandler [WEAK]
EXPORT UART3_IRQHandler [WEAK]
EXPORT PWM1_IRQHandler [WEAK]
EXPORT I2C0_IRQHandler [WEAK]
EXPORT I2C1_IRQHandler [WEAK]
EXPORT I2C2_IRQHandler [WEAK]
EXPORT SPI_IRQHandler [WEAK]
EXPORT SSP0_IRQHandler [WEAK]
EXPORT SSP1_IRQHandler [WEAK]
EXPORT PLL0_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT EINT0_IRQHandler [WEAK]
EXPORT EINT1_IRQHandler [WEAK]
EXPORT EINT2_IRQHandler [WEAK]
EXPORT EINT3_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT BOD_IRQHandler [WEAK]
EXPORT USB_IRQHandler [WEAK]
EXPORT CAN_IRQHandler [WEAK]
EXPORT DMA_IRQHandler [WEAK]
EXPORT I2S_IRQHandler [WEAK]
EXPORT ENET_IRQHandler [WEAK]
EXPORT RIT_IRQHandler [WEAK]
EXPORT MCPWM_IRQHandler [WEAK]
EXPORT QEI_IRQHandler [WEAK]
EXPORT PLL1_IRQHandler [WEAK]
EXPORT USBActivity_IRQHandler [WEAK]
EXPORT CANActivity_IRQHandler [WEAK]

WDT_IRQHandler
TIMER0_IRQHandler
TIMER1_IRQHandler
TIMER2_IRQHandler
TIMER3_IRQHandler
UART0_IRQHandler
UART1_IRQHandler
UART2_IRQHandler
UART3_IRQHandler
PWM1_IRQHandler
I2C0_IRQHandler
I2C1_IRQHandler
I2C2_IRQHandler
SPI_IRQHandler
SSP0_IRQHandler
SSP1_IRQHandler
PLL0_IRQHandler
RTC_IRQHandler
EINT0_IRQHandler
EINT1_IRQHandler
EINT2_IRQHandler
EINT3_IRQHandler
ADC_IRQHandler
BOD_IRQHandler
USB_IRQHandler
CAN_IRQHandler
DMA_IRQHandler
I2S_IRQHandler
ENET_IRQHandler
RIT_IRQHandler
MCPWM_IRQHandler
QEI_IRQHandler
PLL1_IRQHandler
USBActivity_IRQHandler
CANActivity_IRQHandler

B .

ENDP


ALIGN


; User Initial Stack & Heap

IF :DEF:__MICROLIB

EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit

ELSE

IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap

LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR

ALIGN

ENDIF


END

Спасибо.
Go to the top of the page
 
+Quote Post
aaarrr
сообщение Nov 4 2017, 14:49
Сообщение #2


Гуру
******

Группа: Свой
Сообщений: 10 713
Регистрация: 11-12-04
Пользователь №: 1 448



Инициализация производится в __main. Но так как Reset_Handler объявлен как WEAK, разбирайтесь, что там оказалось на самом деле.
Go to the top of the page
 
+Quote Post
doom13
сообщение Nov 4 2017, 14:52
Сообщение #3


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



Цитата(aaarrr @ Nov 4 2017, 17:49) *
Инициализация производится в __main. Но так как Reset_Handler объявлен как WEAK, разбирайтесь, что там оказалось на самом деле.

__main == main() так?
Go to the top of the page
 
+Quote Post
aaarrr
сообщение Nov 4 2017, 15:08
Сообщение #4


Гуру
******

Группа: Свой
Сообщений: 10 713
Регистрация: 11-12-04
Пользователь №: 1 448



Цитата(doom13 @ Nov 4 2017, 17:52) *
__main == main() так?

НЕТ!
Go to the top of the page
 
+Quote Post
doom13
сообщение Nov 4 2017, 15:08
Сообщение #5


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



Вроде не так, почему тогда при выполнении
Код
LDR     R0, =__main
BX      R0

сразу переходит на main()? Хотя каких-то два шага делает???
Go to the top of the page
 
+Quote Post
aaarrr
сообщение Nov 4 2017, 15:10
Сообщение #6


Гуру
******

Группа: Свой
Сообщений: 10 713
Регистрация: 11-12-04
Пользователь №: 1 448



Цитата(doom13 @ Nov 4 2017, 18:08) *
Вроде не так, почему тогда при выполнении
Код
LDR     R0, =__main
  BX      R0

сразу переходит на main()?

Переходит где - в отладчике? Сравните содержимое R0 перед BX с адресом main().
Go to the top of the page
 
+Quote Post
doom13
сообщение Nov 4 2017, 15:39
Сообщение #7


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



Перед заходом в main() бегает по этому куску программы (делает пару шагов, толком не могу проследить последовательность)
CODE
__main:
000000cc: bl 0xd4 <__scatterload_rt2>
000000d0: bl 0x148 <__rt_entry_sh>
__scatterload_rt2:
000000d4: add r0, pc, #40 ; (adr r0, 0x100 <__scatterload_null+30>)
000000d6: ldmia.w r0, {r10, r11}
000000da: add r10, r0
000000dc: add r11, r0
000000de: sub.w r7, r10, #1
000000e2: cmp r10, r11
000000e4: bne.n 0xea <__scatterload_rt2+22>
000000e6: bl 0x148 <__rt_entry_sh>
000000ea: subw lr, pc, #9
000000ee: ldmia.w r10!, {r0, r1, r2, r3}
000000f2: tst.w r3, #1
000000f6: it ne
000000f8: subne r3, r7, r3
000000fa: orr.w r3, r3, #1
000000fe: bx r3
00000100: asrs r0, r0, #29
00000102: movs r0, r0
00000104: asrs r0, r4, #29
00000106: movs r0, r0
__scatterload_copy:
00000108: subs r2, #16
0000010a: itt cs
0000010c: ldmiacs r0!, {r3, r4, r5, r6}
0000010e: stmiacs r1!, {r3, r4, r5, r6}
00000110: bhi.n 0x108 <__scatterload_copy>
00000112: lsls r2, r2, #29
00000114: itt cs
00000116: ldmiacs r0!, {r4, r5}
00000118: stmiacs r1!, {r4, r5}
0000011a: itt mi
0000011c: ldrmi r4, [r0, #0]
0000011e: strmi r4, [r1, #0]
00000120: bx lr
00000122: movs r0, r0
__scatterload_zeroinit:
00000124: movs r3, #0
__scatterload_zeroinit:
00000125: movs r3, #0
00000127: movs r4, #0
00000129: movs r5, #0
0000012b: movs r6, #0
0000012d: subs r2, #16
0000012f: it cs
00000131: stmiacs r1!, {r3, r4, r5, r6}
00000133: bhi.n 0x12c <__scatterload_zeroinit+8>
00000135: lsls r2, r2, #29
00000137: it cs
00000139: stmiacs r1!, {r4, r5}
0000013b: it mi
0000013d: strmi r3, [r1, #0]
0000013f: bx lr


__scatterload должна выполнить всю инициализацию? Правильно? Тогда вопрос, может проблема в моём scatter-file???

Из DAI0241B - ARM Compiler C Library Startup and Initialization
Цитата
3.1 __scatterload
Application code and data can be in a root region or a non-root region. Root regions have
the same load-time and execution-time addresses. Non-root regions have different loadtime and execution-time addresses. The root region contains a region table output by the
ARM linker.
The region table contains the addresses of the non-root code and data regions that require
initialization. The region table also contains a function pointer that indicates what
initialization is needed for the region, for example a copying, zeroing, or decompressing
function.
__scatterload goes through the region table and initializes the various execution-time
regions. The function:
• Initializes the Zero Initialized (ZI) regions to zero
• Copies or decompresses the non-root code and data region from their load-time
locations to the execute-time regions.
__main always calls this function during startup before calling __rt_entry.
Go to the top of the page
 
+Quote Post
aaarrr
сообщение Nov 4 2017, 15:50
Сообщение #8


Гуру
******

Группа: Свой
Сообщений: 10 713
Регистрация: 11-12-04
Пользователь №: 1 448



Цитата(doom13 @ Nov 4 2017, 18:39) *
__scatterload должна выполнить всю инициализацию? Правильно? Тогда вопрос, может проблема в моём scatter-file???

Должна. С файлом все в порядке на перывй взгляд. А что и где именно не инициалазируетя?
Go to the top of the page
 
+Quote Post
doom13
сообщение Nov 4 2017, 15:58
Сообщение #9


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



Код
/*
* main.c
*/

__attribute__((zero_init)) int x0; // тут всё четко, будет 0                                      (положит в .bss)
int x1 = 1024;                     // тут увидим -1 (т.е. 0хFFFFFFFF)                             (положит в .data)
int x2;                            // тут, вроде должно нулём проинициализировать, а получим -1   (положит в .data)

int main()
{
    return (x0 > x1) ? (x2 > x1) : 0;
}
Go to the top of the page
 
+Quote Post
aaarrr
сообщение Nov 4 2017, 16:02
Сообщение #10


Гуру
******

Группа: Свой
Сообщений: 10 713
Регистрация: 11-12-04
Пользователь №: 1 448



map файл покажите.
Go to the top of the page
 
+Quote Post
doom13
сообщение Nov 4 2017, 16:11
Сообщение #11


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



CODE

Memory Map of the image

Image Entry point : 0x000000cd

Load Region LR_IROM1 (Base: 0x00000000, Size: 0x00001874, Max: 0x00040000, ABSOLUTE)

Execution Region ER_IROM1 (Base: 0x00000000, Size: 0x00001860, Max: 0x00040000, ABSOLUTE)

Base Addr Size Type Attr Idx E Section Name Object

0x00000000 0x000000cc Data RO 89 RESET startup_LPC17xx.o
0x000000cc 0x00000008 Code RO 223 * !!!main c_w.l(__main.o)
0x000000d4 0x00000034 Code RO 225 !!!scatter c_w.l(__scatter.o)
0x00000108 0x0000001a Code RO 392 !!handler_copy c_w.l(__scatter_copy.o)
0x00000122 0x00000002 PAD
0x00000124 0x0000001c Code RO 394 !!handler_zi c_w.l(__scatter_zi.o)
0x00000140 0x00000002 Code RO 262 .ARM.Collect$$libinit$$00000000 c_w.l(libinit.o)
0x00000142 0x00000000 Code RO 275 .ARM.Collect$$libinit$$00000002 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 277 .ARM.Collect$$libinit$$00000004 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 280 .ARM.Collect$$libinit$$0000000A c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 282 .ARM.Collect$$libinit$$0000000C c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 284 .ARM.Collect$$libinit$$0000000E c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 287 .ARM.Collect$$libinit$$00000011 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 289 .ARM.Collect$$libinit$$00000013 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 291 .ARM.Collect$$libinit$$00000015 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 293 .ARM.Collect$$libinit$$00000017 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 295 .ARM.Collect$$libinit$$00000019 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 297 .ARM.Collect$$libinit$$0000001B c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 299 .ARM.Collect$$libinit$$0000001D c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 301 .ARM.Collect$$libinit$$0000001F c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 303 .ARM.Collect$$libinit$$00000021 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 305 .ARM.Collect$$libinit$$00000023 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 307 .ARM.Collect$$libinit$$00000025 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 311 .ARM.Collect$$libinit$$0000002C c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 313 .ARM.Collect$$libinit$$0000002E c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 315 .ARM.Collect$$libinit$$00000030 c_w.l(libinit2.o)
0x00000142 0x00000000 Code RO 317 .ARM.Collect$$libinit$$00000032 c_w.l(libinit2.o)
0x00000142 0x00000002 Code RO 318 .ARM.Collect$$libinit$$00000033 c_w.l(libinit2.o)
0x00000144 0x00000002 Code RO 349 .ARM.Collect$$libshutdown$$00000000 c_w.l(libshutdown.o)
0x00000146 0x00000000 Code RO 375 .ARM.Collect$$libshutdown$$00000002 c_w.l(libshutdown2.o)
0x00000146 0x00000000 Code RO 377 .ARM.Collect$$libshutdown$$00000004 c_w.l(libshutdown2.o)
0x00000146 0x00000000 Code RO 380 .ARM.Collect$$libshutdown$$00000007 c_w.l(libshutdown2.o)
0x00000146 0x00000000 Code RO 383 .ARM.Collect$$libshutdown$$0000000A c_w.l(libshutdown2.o)
0x00000146 0x00000000 Code RO 385 .ARM.Collect$$libshutdown$$0000000C c_w.l(libshutdown2.o)
0x00000146 0x00000000 Code RO 388 .ARM.Collect$$libshutdown$$0000000F c_w.l(libshutdown2.o)
0x00000146 0x00000002 Code RO 389 .ARM.Collect$$libshutdown$$00000010 c_w.l(libshutdown2.o)
0x00000148 0x00000000 Code RO 227 .ARM.Collect$$rtentry$$00000000 c_w.l(__rtentry.o)
0x00000148 0x00000000 Code RO 233 .ARM.Collect$$rtentry$$00000002 c_w.l(__rtentry2.o)
0x00000148 0x00000006 Code RO 245 .ARM.Collect$$rtentry$$00000004 c_w.l(__rtentry4.o)
0x0000014e 0x00000000 Code RO 235 .ARM.Collect$$rtentry$$00000009 c_w.l(__rtentry2.o)
0x0000014e 0x00000004 Code RO 236 .ARM.Collect$$rtentry$$0000000A c_w.l(__rtentry2.o)
0x00000152 0x00000000 Code RO 238 .ARM.Collect$$rtentry$$0000000C c_w.l(__rtentry2.o)
0x00000152 0x00000008 Code RO 239 .ARM.Collect$$rtentry$$0000000D c_w.l(__rtentry2.o)
0x0000015a 0x00000002 Code RO 266 .ARM.Collect$$rtexit$$00000000 c_w.l(rtexit.o)
0x0000015c 0x00000000 Code RO 322 .ARM.Collect$$rtexit$$00000002 c_w.l(rtexit2.o)
0x0000015c 0x00000004 Code RO 323 .ARM.Collect$$rtexit$$00000003 c_w.l(rtexit2.o)
0x00000160 0x00000006 Code RO 324 .ARM.Collect$$rtexit$$00000004 c_w.l(rtexit2.o)
0x00000166 0x00000002 PAD
0x00000168 0x00000004 Code RO 1 .rev16_text GPIO_LPC17xx.o
0x0000016c 0x00000004 Code RO 57 .rev16_text PIN_LPC17xx.o
0x00000170 0x00000004 Code RO 97 .rev16_text system_LPC17xx.o
0x00000174 0x00000004 Code RO 127 .rev16_text SPI_LPC17xx.o
0x00000178 0x00000004 Code RO 181 .rev16_text main.o
0x0000017c 0x00000004 Code RO 2 .revsh_text GPIO_LPC17xx.o
0x00000180 0x00000004 Code RO 58 .revsh_text PIN_LPC17xx.o
0x00000184 0x00000004 Code RO 98 .revsh_text system_LPC17xx.o
0x00000188 0x00000004 Code RO 128 .revsh_text SPI_LPC17xx.o
0x0000018c 0x00000004 Code RO 182 .revsh_text main.o
0x00000190 0x00000006 Code RO 3 .rrx_text GPIO_LPC17xx.o
0x00000196 0x00000002 PAD
0x00000198 0x00000006 Code RO 59 .rrx_text PIN_LPC17xx.o
0x0000019e 0x00000002 PAD
0x000001a0 0x00000006 Code RO 99 .rrx_text system_LPC17xx.o
0x000001a6 0x00000002 PAD
0x000001a8 0x00000006 Code RO 129 .rrx_text SPI_LPC17xx.o
0x000001ae 0x00000002 PAD
0x000001b0 0x00000006 Code RO 183 .rrx_text main.o
0x000001b6 0x00000002 PAD
0x000001b8 0x000000cc Code RO 4 .text GPIO_LPC17xx.o
0x00000284 0x00000040 Code RO 91 .text startup_LPC17xx.o
0x000002c4 0x00000034 Code RO 184 .text main.o
0x000002f8 0x00000002 Code RO 338 .text c_w.l(use_no_semi.o)
0x000002fa 0x00000000 Code RO 340 .text c_w.l(indicate_semi.o)
0x000002fa 0x00000002 PAD
0x000002fc 0x00000004 Code RO 90 .ARM.__at_0x02FC startup_LPC17xx.o
0x00000300 0x0000013c Code RO 60 .text PIN_LPC17xx.o
0x0000043c 0x000002f0 Code RO 100 .text system_LPC17xx.o
0x0000072c 0x00000ef4 Code RO 130 .text SPI_LPC17xx.o
0x00001620 0x000000ee Code RO 217 .text c_w.l(lludivv7m.o)
0x0000170e 0x0000004e Code RO 219 .text c_w.l(rt_memclr_w.o)
0x0000175c 0x00000006 Code RO 221 .text c_w.l(heapauxi.o)
0x00001762 0x0000004a Code RO 249 .text c_w.l(sys_stackheap_outer.o)
0x000017ac 0x00000012 Code RO 251 .text c_w.l(exit.o)
0x000017be 0x00000002 PAD
0x000017c0 0x00000008 Code RO 263 .text c_w.l(libspace.o)
0x000017c8 0x0000000c Code RO 319 .text c_w.l(sys_exit.o)
0x000017d4 0x0000006c Data RO 132 .constdata SPI_LPC17xx.o
0x00001840 0x00000020 Data RO 390 Region$$Table anon$$obj.o


Execution Region RW_IRAM1 (Base: 0x10000000, Size: 0x000040a8, Max: 0x00008000, ABSOLUTE)

Base Addr Size Type Attr Idx E Section Name Object

0x10000000 0x00000004 Data RW 101 .data system_LPC17xx.o
0x10000004 0x0000000c Data RW 133 .data SPI_LPC17xx.o
0x10000010 0x00000004 Data RW 186 .data main.o
0x10000014 0x00000028 Zero RW 131 .bss SPI_LPC17xx.o
0x1000003c 0x00000008 Zero RW 185 .bss main.o
0x10000044 0x00000060 Zero RW 264 .bss c_w.l(libspace.o)
0x100000a4 0x00000004 PAD
0x100000a8 0x00002000 Zero RW 88 HEAP startup_LPC17xx.o
0x100020a8 0x00002000 Zero RW 87 STACK startup_LPC17xx.o


==============================================================================


scatter-file немного изменял, для этого мапа такой
Код
LR_IROM1 0x00000000 0x40000 {   ; load region size_region
  ER_IROM1 0x00000000 0x40000 { ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_IRAM1 0x10000000 0x8000 {
   *.o (.bss)
   *.o (.data)
    .ANY (+RW +ZI)
  }
}
Go to the top of the page
 
+Quote Post
aaarrr
сообщение Nov 4 2017, 16:18
Сообщение #12


Гуру
******

Группа: Свой
Сообщений: 10 713
Регистрация: 11-12-04
Пользователь №: 1 448



Странно. Лучше посмотреть пошагово, что происходит в scatterload. Там явно не может парой шагов дело ограничиваться.
Go to the top of the page
 
+Quote Post
doom13
сообщение Nov 4 2017, 17:10
Сообщение #13


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



Дофига что делает до main(), но толку мало,
последовательность выполняемых инструкций:
CODE

LDR R0, =__main
BX R0


__main:
000000cc: bl 0xd4 <__scatterload_rt2> ; unpredictable branch in IT block\n


__scatterload_rt2:
000000d4: add r0, pc, #40 ; (adr r0, 0x100 <__scatterload_null+30>)
000000d6: ldmia.w r0, {r10, r11}
000000da: add r10, r0
000000dc: add r11, r0
000000de: sub.w r7, r10, #1
000000e2: cmp r10, r11
000000e4: bne.n 0xea <__scatterload_rt2+22>

000000ea: subw lr, pc, #9
000000ee: ldmia.w r10!, {r0, r1, r2, r3}
000000f2: tst.w r3, #1
000000f6: it ne
000000f8: subne r3, r7, r3
000000fa: orr.w r3, r3, #1
000000fe: bx r3

__scatterload_copy:
00000108: subs r2, #16
0000010a: itt cs
0000010c: ldmiacs r0!, {r3, r4, r5, r6}
0000010e: stmiacs r1!, {r3, r4, r5, r6}
00000110: bhi.n 0x108 <__scatterload_copy>
00000112: lsls r2, r2, #29
00000114: itt cs
00000116: ldmiacs r0!, {r4, r5}
00000118: stmiacs r1!, {r4, r5}
0000011a: itt mi
0000011c: ldrmi r4, [r0, #0]
0000011e: strmi r4, [r1, #0]
00000120: bx lr

__scatterload_rt2:

000000e2: cmp r10, r11
000000e4: bne.n 0xea <__scatterload_rt2+22>
000000e6: bl 0x148 <__rt_entry_sh>
000000ea: subw lr, pc, #9
000000ee: ldmia.w r10!, {r0, r1, r2, r3}
000000f2: tst.w r3, #1
000000f6: it ne
000000f8: subne r3, r7, r3
000000fa: orr.w r3, r3, #1
000000fe: bx r3

__scatterload_zeroinit:
00000124: movs r3, #0
00000126: movs r4, #0
00000128: movs r5, #0
0000012a: movs r6, #0

0000012c: subs r2, #16 // ТУТ ДОЛГО КРУТИЛСЯ
0000012e: it cs //
00000130: stmia r1!, {r3, r4, r5, r6} //
00000132: bhi.n 0x12c <__scatterload_zeroinit+8> //

00000134: lsls r2, r2, #29
00000136: it cs
00000138: stmiacs r1!, {r4, r5}
0000013a: it mi
0000013c: strmi r3, [r1, #0]
0000013e: bx lr

__scatterload_rt2
000000e2: cmp r10, r11
000000e4: bne.n 0xea <__scatterload_rt2+22>
000000e6: bl 0x148 <__rt_entry_sh>

__rt_entry_sh:
00000148: bl 0x1762 <__user_setup_stackheap>

__user_setup_stackheap:
00001762: mov r5, lr
00001764: bl 0x17c0 <__user_libspace>

__user_libspace:
000017c0: ldr r0, [pc, #0] ; (0x17c4 <__user_libspace+4>)
000017c2: bx lr

__user_setup_stackheap:

00001768: mov lr, r5
0000176a: movs r5, r0
0000176c: mov r1, sp
0000176e: mov r3, r10
00001770: bic.w r0, r0, #7
00001774: mov sp, r0
00001776: add sp, #96 ; 0x60
00001778: push {r5, lr}
0000177a: bl 0x2a0 <__user_initial_stackheap>

__user_initial_stackheap:
000002a0: ldr r0, [pc, #16] ; (0x2b4 <__user_initial_stackheap+20>)
332 LDR R1, =(Stack_Mem + Stack_Size)
000002a2: ldr r1, [pc, #20] ; (0x2b8 <__user_initial_stackheap+24>)
333 LDR R2, = (Heap_Mem + Heap_Size)
000002a4: ldr r2, [pc, #20] ; (0x2bc <__user_initial_stackheap+28>)
334 LDR R3, = Stack_Mem
000002a6: ldr r3, [pc, #24] ; (0x2c0 <__user_initial_stackheap+32>)
335 BX LR
000002a8: bx lr

__user_setup_stackheap:

0000177e: ldmia.w sp!, {r5, lr}
00001782: mov.w r6, #0
00001786: mov.w r7, #0
0000178a: mov.w r8, #0
0000178e: mov.w r11, #0
00001792: bic.w r1, r1, #7
00001796: mov r12, r5
00001798: stmia.w r12!, {r6, r7, r8, r11}
0000179c: stmia.w r12!, {r6, r7, r8, r11}
000017a0: stmia.w r12!, {r6, r7, r8, r11}
000017a4: stmia.w r12!, {r6, r7, r8, r11}
000017a8: mov sp, r1
000017aa: bx lr

__rt_entry_sh:

0000014c: mov r1, r2

__rt_entry_postsh_1:
0000014e: bl 0x140 <__rt_lib_init>

__rt_lib_init:
00000140: push {r0, r1, r2, r3, r4, lr}

__rt_lib_init_user_alloc_1:
00000142: pop {r0, r1, r2, r3, r4, pc}

__rt_entry_postli_1:
00000152: bl 0x2c6 <main>

main:
000002c6: ldr r0, [pc, #36] ; (0x2ec)



Go to the top of the page
 
+Quote Post
aaarrr
сообщение Nov 4 2017, 17:13
Сообщение #14


Гуру
******

Группа: Свой
Сообщений: 10 713
Регистрация: 11-12-04
Пользователь №: 1 448



.data должны заполниться в __scatterload_copy.
Go to the top of the page
 
+Quote Post
doom13
сообщение Nov 4 2017, 17:55
Сообщение #15


Профессионал
*****

Группа: Свой
Сообщений: 1 404
Регистрация: 11-03-11
Из: Минск, Беларусь
Пользователь №: 63 539



Да, заполняются crying.gif
Код
          __scatterload_copy:
00000108:   subs    r2, #16
0000010a:   itt     cs

; тут в r0 значение 0x1860
; после выполнения #0000010c в r0 = 0x1870, r3, r4, r5, r6 = 0xffffffff

0000010c:   ldmiacs r0!, {r3, r4, r5, r6}

; после выполнения #0000010e в r1 = 0x10000010
;
; согласно map-file
; 0x10000010   0x00000008   Data   RW          186    .data               main.o
;
; в main() две глобальные переменные
; int x1 = 1024;
; int x2;
;
; x1, x2 в окне Expressions - значения какой-то мусор

0000010e:   stmiacs r1!, {r3, r4, r5, r6}

; инструкция #00000110 вернула на #00000108
00000110:   bhi.n   0x108 <__scatterload_copy>


00000108:   subs    r2, #16
0000010a:   itt     cs
0000010c:   ldmiacs r0!, {r3, r4, r5, r6}
0000010e:   stmiacs r1!, {r3, r4, r5, r6}
00000110:   bhi.n   0x108 <__scatterload_copy>
00000112:   lsls    r2, r2, #29
00000114:   itt     cs
00000116:   ldmiacs r0!, {r4, r5}
00000118:   stmiacs r1!, {r4, r5}

; записало 0xffffffff в глобальные переменные x1, x2

только 0xffffffff-ми

0xFFFFFFFF, похоже, берёт с левых адресов флэша?
Go to the top of the page
 
+Quote Post

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

 


RSS Текстовая версия Сейчас: 22nd June 2025 - 11:09
Рейтинг@Mail.ru


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