0

I am trying to write a bootloader according to armv7 architecture using armv7 assembly instruction set ? Ex:

Setting cpu to svc mode on reset:

mrs r0, cpsr
bic r0, r0,#0x1f
orr r0, r0,#0xd3
msr cpsr, r0
mov pc, lr

Will the same bootloader work on armv8. As armv8 also supports aarch32 . But on the other hand it also has many differences.

sourav punoriyar
  • 830
  • 8
  • 18
  • it already boots into svc mode right? why set to svc mode if it is already there. ARMv7: "A processor enters Supervisor mode on Reset." – old_timer Jun 04 '17 at 11:29
  • In an implementation where the highest implemented Exception level is using AArch32, if that Exception level is EL3 or EL1, a PE enters Supervisor mode on Reset. – old_timer Jun 04 '17 at 11:29
  • Ill let you read the rest on your own, or just read out the cpsr on boot as early as you can and save it or view it... – old_timer Jun 04 '17 at 11:34
  • Thanks..upon reset it should already be in svc.i have taken these lines from uboot. Dont know why it is exactly needed . – sourav punoriyar Jun 04 '17 at 13:13
  • Its true in hyp and aarch64 ,i m stuck.What if it is not in hyp and the execution state is aarch32 ?.I am trying to replace uboot with mine for beaglebone black which is v8. – sourav punoriyar Jun 04 '17 at 13:17
  • Thanks a lot. BBB is cortex-A8 which has armv7-a micro-architecture. – sourav punoriyar Jun 05 '17 at 05:17
  • very early on in your bootloader simply read it then display it there or leave it so you can read it with a debugger, etc...THEN...try to understand why it is or isnt in some mode so that you can then put it in the mode you like. – old_timer Jun 05 '17 at 17:35

1 Answers1

1

Not necessarily for a couple of reasons, first off if you are in hyp mode you cant get back from that that easily. Second, if you are in aarch64 mode then that is a different instruction set. So in part it depends on where this code is how early in the bootloader is this truly the bootloader or do you have other code that comes before this (that puts you in a state that code like this won't work).

Short answer, no this code not only won't always work for armv8 it won't always work for armv7.

halfer
  • 19,824
  • 17
  • 99
  • 186
old_timer
  • 69,149
  • 8
  • 89
  • 168