Bare 1-5 feedback
Bare 1:
under point 2:
"The error occurs and then sends it further up and into panic and ending up in asm/lib" is correct, but I'd like to see you expand on it, try to dig a little deeper! Why do we have so many calls to panic?
Under point 3:
"The panic makes sense because x overflows by increasing the max (2^32 = 4294967295) by 1." is correct, but why does it trigger the panic? Hint: It is (insert answer here) behaviour.
Under point 4:
"load r0 with the value that stackpointer points to." is correct, but it's not a full answer. There is an offset we use too, it just happens to be 0.
Under point 5:
"When calling bkpt when not in debug will cause a panic.", this answer is wrong, as we have yet to get rid of our overflow panic. I just ran the test agin on my nucleo and it didn't panic at the bkpt for me.
"// Dump of assembler code for function rtic_bare1::APP::main:
/* 0x08000eae <+0>: push {r7, lr}
0x08000eb0 <+2>: mov r7, sp
0x08000eb2 <+4>: sub sp, #56 ; 0x38
=> 0x08000eb4 <+6>: bl 0x8000faa lib::__cpsid
0x08000eb8 <+10>: movw r0, #0
0x08000ebc <+14>: movw r4, #60688 ; 0xed10
0x08000ec0 <+18>: movt r0, #8192 ; 0x2000
0x08000ec4 <+22>: movs r1, #1 (closed)
0x08000ec6 <+24>: strb r1, [r0, #0]
0x08000ec8 <+26>: add r0, sp, #4 (closed)
0x08000eca <+28>: movt r4, #57344 ; 0xe000
0x08000ece <+32>: str r0, [sp, #20]
0x08000ed0 <+34>: mov r0, r4
0x08000ed2 <+36>: strd r4, r4, [sp, #28]
0x08000ed6 <+40>: bl 0x8000f78 <_ZN4core4cell19UnsafeCellLT
T$GT$3get17hc981151b10f99f20E>
0x08000eda <+44>: bl 0x8000f46 <_ZN4core3ptr13read_volatile17hb977623ea709e27cE>
0x08000ede <+48>: orr.w r5, r0, #2 (closed)
0x08000ee2 <+52>: str r0, [sp, #24]
0x08000ee4 <+54>: mov r0, r4
0x08000ee6 <+56>: str r4, [sp, #36] ; 0x24
0x08000ee8 <+58>: str r5, [sp, #40] ; 0x28
0x08000eea <+60>: bl 0x8000f78 <_ZN4core4cell19UnsafeCellLT
T$GT$3get17hc981151b10f99f20E>
0x08000eee <+64>: mov r1, r5
0x08000ef0 <+66>: bl 0x8000f54 <_ZN4core3ptr14write_volatile17h73c310961d025d87E>
0x08000ef4 <+70>: bl 0x8000e84 <rtic_bare1::init>
0x08000ef8 <+74>: bl 0x8000fae lib::__cpsie
0x08000efc <+78>: bl 0x8000fb2 lib::__wfi
0x08000f00 <+82>: b.n 0x8000efc <rtic_bare1::APP::main+78> End of assembler dump. */ " This seems like a lot, might want to look over this point.
The reason we don't have a reference to the panic handler is due to no undefined behaviour being found.
Bare 2:
Under point 3:
"It starts the wait function where it just loops nops.", I don't think this answers the question. What happens if instead of 1_000_000 we use 100?
Bare 3:
Under point 3:
There is some error with your implementation, as you should end up with the exact same answer, that being a difference of 4000016
Bare 4:
Under point 2:
"It is not safe. You create a copy of a register without using borrow checking so Rust consider it unsafe.", it is not inherently unsafe, but under certain conditions it can
Under point 3:
"Thats the whole point with volatile operations.", could you link some reading materials regarding this? I've not come over this information during my research
Bare 5:
The second assert fails for me, seems like there's still some errors for you to work out. Keep in mind that we only want to overwrite certain bits and not all of them, we are modifying our value and not changing it completely.
You'll need some way of either writing directly only to certain bits or you'll need to pull out the entire value and modify it before overwriting everything, I found the 2nd option easier.