the code address is not aligned

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
pengzw
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

Hi,
I'm using IAR(version : 8.42.1) to build a Traveo II CYT2B9 project(tviibe1m_flash_cm0plus_template.eww demo project), but I found the built code address is not aligned, which can cause the cortex-m0 enter the fault, how should I solve this problem?

code_no_aligned.png

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Alfred_Tsang
Moderator
Moderator
Moderator
50 replies posted 50 sign-ins 10 solutions authored

Hi pengzw,

You can check with the following debugger capture view, actually the code is aligned on a memory address multiple of 2 (align 2).

Besides also attached our map and lst file for your reference.

Alfred_Tsang_0-1652771297658.png

Thanks,

View solution in original post

0 Likes
7 Replies
pengzw
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

@Alfred_Tsang 

Can you please help me solve this problem ? Thank you !

I'm using the demo project without any modification to it.  The IAR’s license is  evaluation version with a 32KB limit.

0 Likes
pengzw
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

Can anyone show your map file (generated from IAR) to me ? I want to know if your code address is not aligned.

0 Likes
Alfred_Tsang
Moderator
Moderator
Moderator
50 replies posted 50 sign-ins 10 solutions authored

Hi pengzw,

Sorry for the late response, I got the same map file as you,  but no idea why the map file show the function started at 0x1000'0d55 not align to 2 byte, we might need to check with debugger, will get back to you as soon as possible. 

Alfred_Tsang_0-1652759401519.png

 

Thanks,

0 Likes
lock attach
Attachments are accessible only for community members.
Alfred_Tsang
Moderator
Moderator
Moderator
50 replies posted 50 sign-ins 10 solutions authored

Hi pengzw,

You can check with the following debugger capture view, actually the code is aligned on a memory address multiple of 2 (align 2).

Besides also attached our map and lst file for your reference.

Alfred_Tsang_0-1652771297658.png

Thanks,

0 Likes

Hi @Alfred_Tsang 

Thank you for your reply !

I re-checked the failure,  it wasn't caused by an unaligned address access.

The reason is that I chose the device version incorrectly, which caused the program to crash in the "InitRamEcc" function.

device_version.png

The problem of the chip crashing has been solved. But there is still some knowledge about the ARM processor that I have to contiune study.


Thank you !

pengzw
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

Hi, @Alfred_Tsang 

Initially, what confused me is that the address where  the "BLX" instruction jumps to is unaligned, as show below.

blx_address.png

The image below has answered part of my questions.

thumb_interworking.png

0 Likes
Alfred_Tsang
Moderator
Moderator
Moderator
50 replies posted 50 sign-ins 10 solutions authored

Hi pengzw,

Sorry for the long wait.
For the different address between map file and the program counter (PC),
I believe the reason because of the PC should not return an odd number address, when you write to PC, LSB of value is loaded into the EPSR T-bit.
In order words, you can only find the value of PC register is an even number.
For more information, please refer to 'Cortex-M4 Technical Reference Manual'and'Cortex-M4 devices Generic User Guide'

 

Alfred_Tsang_1-1653043243692.png

 

Thanks,

0 Likes