CP15 system control register (SCTLR), bit.A = 0, (bit.U = 1, which is already set to 1 by default for ARMv7 and cannot be changed).
The address space accessed must be Normal memory, and accessing Device memory or Strongly memory will trigger a Data Abort with an alignment fault. If the MMU is disabled, all memory will be treated as Strongly memory (I can't find the source of this sentence, it comes from the reply email of ARM support). So the MMU must be enabled, and the memory type is determined by C, B, TEX[2:0] of the page table entry. This part can be found in
B3.7 Memory region attributes.
Example
MRS r0, CPSR ORR r0, r0, #(PSR_I_BIT|PSR_F_BIT) ; Disable IRQ & FIQ MSR CPSR_c, r0 ; Disable MMU stuff and caches MRC p15, 0, r0, c1, c0, 0 ; read control register to r0 BIC r0, r0, #0x000f ; clear W(Write buffer), C(Cache), A(Align), M(MMU) bits BIC r0, r0, #0x1100 ; clear I(ICache), S(System protection) bits MCR p15, 0, r0, c1, c0, 0 ; write control register. stack_setup LDR r0, =|Image$$ZI$$Limit| ADD r0, r0, #STACK_SIZE_SVC MSR CPSR_c, #(MODE_SVC :OR: PSR_F_BIT :OR: PSR_I_BIT) MOV sp, r0 mmu_setup LDR r2, =MMU_TABLE_BASE ; mmu page base address MCR p15, 0, r2, c2, c0, 0 ; write mmu page base address BL _cpu_mmu_init LDR r0, =0x89 LDRH r1, [r0]
About the Compiler
In Realview, if the target processor is ARMv6, ARMv7-A (such as Cortex-A8), or ARMv7-R, the default option of the compiler is --unaligned_access. If a version before ARMv6 or a processor of the ARMv7-M system is selected, the default option is --no_unaligned_access.
For the option --no_unaligned_access, the compiler will automatically convert the C language access to variables with unaligned addresses into several byte operations. For example:
__packed struct usb_endpoint_descriptor { u8 bLength; u16 wMaxPacketSize; u8 bDescriptorType; u8 bEndpointAddress; u8 bmAttributes; u8 bInterval; } ; int main(void) { volatile struct usb_endpoint_descriptor ep; ep.wMaxPacketSize = 0x200; while(1); return 0; } If compiled with the --no_unaligned_access option, its disassembled code is as follows: main 0xe100c5f0: e92d400c .@-. PUSH {r2,r3,lr} 0xe100c5f4: e3a00c02 .... MOV r0,#0x200 0xe100c5f8: e5cd0001 .... STRB r0,[sp,#1] 0xe100c5fc: e1a00420 ... LSR r0,r0,#8 0xe100c600: e5cd0002 .... STRB r0,[sp,#2] 0xe100c604: eafffffe .... B 0xe100c604 ; main + 20 If compiled with the --unaligned_access option, its disassembled code is as follows: main 0xe100c5f0: e92d400c .@-. PUSH {r2,r3,lr} 0xe100c5f4: e3a00c02 .... MOV r0,#0x200 0xe100c5f8: e1cd00b1 .... STRH r0,[sp,#1] 0xe100c5fc: eafffffe .... B 0xe100c5fc ; main + 12
If your target platform is ARMv6 or ARMv7-AR, but the MMU is disabled in your code, you should manually add the compilation option --no_unaligned_access to let the compiler handle unaligned access for you.
Previous article:ARMv8 instruction learning (1)
Next article:ARM的System Mode
Recommended ReadingLatest update time:2024-11-16 14:59
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to not set a password in AP mode
- LCD Segment Screen Screen Printing Notes
- hfss18 version 3D image setting problem
- The network transformer output does not connect to RJ45, but uses a custom interface!
- EEWORLD University Hall----Live Replay: TI Sitara? Multi-protocol Industrial Communication Optimization Solution, PLC Demo Real-time Demonstration
- [NXP Rapid IoT Review] Reduce the CPU frequency (K64) to save power
- CC1310 Two-wire Serial Bootloader Solution
- Filter applications for different scenarios - harmonics
- 4.3-inch screen design
- How does AD19 transfer a BMP format logo image to PCB?