‎2020-08-19 02:57 AM
For example how can i do this with stm32f030cc?
Solved! Go to Solution.
‎2020-08-22 10:30 AM
You can run code in RAM then when i understand you can start static code in flash, in this load to ram asm prepared bin, jump to it, return to flash change ramcode and do this neverendly...
‎2020-08-22 11:53 AM
The orrs r1,r1 causes the processor to reevaluate the flags, for example Z and N flags. I'm checking if bit 31 is set or not, and branching based on that.
The subroutine is called with blx _UnlockFlash which saves the return address into the link register.
>>I succeed write and read but how will i run this hexadecimal code of like ldr r0, =(0x1) ?
What do you expect 'ldr r0, =(0x1)' would do? Illustrate entry and exit conditions, it's hard to empath what you mean here.
You want to load R0 with ONE?
‎2020-08-22 12:20 PM
thanks clive1,
I want to save some codes to the memory like
ldr r3, =(0x5)
ldr r2, =(0x3)
add r2, r3
then i want to run these codes from memory.(These codes will not be in its program so it will not be function)
How to execute code from external flash on STM32F407
How will i run a code from flash ?
Can you help me clive1 ?
‎2020-08-22 12:27 PM
Thank you.
I want to do this exactly.
But problem is hard fault.
Maybe i am doing wrong something.
I am using clive1 's codes
I cant branch to the ram or something, just in program.
‎2020-08-22 01:17 PM
To see the generate opcodes you would look at a listing file.
Generally for small constants you can load immediates, for value that don't work that way you need to load them from the literal pool.
Perhaps refer to some ARM assembly language texts
‎2020-08-23 05:42 AM
I hope you can understand what did i do in this codes :grinning_face: .
I change value of address of nop codes.
ldr r1, =(0x0800040c) // address of first saver nop
ldr r0, =(0x2555) ; ldr r5, =(0x55)
str r0, [r1]
ldr r1, =(0x08000410) // address of second saver nop
ldr r0, =(0x2455) ; ldr r4, =(0x55)
str r0, [r1]
nop // first saver nop) ldr r5, =(0x55)
nop // nop this should nop because it is stucking when you load new code here
nop // second saver nop) ldr r4, =(0x55)
;nop // if you will save new code this nop should nop
;nop // if you save new code, you can save new code here
‎2020-08-23 06:08 AM
Ok, so "self modifying code"
This would be better done in RAM, as the flash writing is subtly different, and does expect the words being written to be in the erased state.
I'll note the opcodes are 16-bit wide, not 32-bit
Branching to RAM is possible, just remember that 16-Thumb code needs you to branch to the ODD address, not the EVEN one.
‎2020-08-23 03:37 PM
"This would be better done in RAM"
You are right but i could not do this because i could not prepare ram to store data but if i can do, i need to return back to the program.
I need to learn a lot :smiling_face_with_smiling_eyes:.
If i find a way that how will i do that with ram, i will add codes here.
I think that i need learn this "Direct memory access controller (DMA)"
Thank you everyone.