[riot-notifications] [RIOT-OS/RIOT] cpu/cortexm: force irq state variable to RAM in cortexm_sleep() (#8518)

Francisco Acosta notifications at github.com
Tue Feb 6 17:32:15 CET 2018


Some findings...

Current master (crashes):
```asm
00000000 <pm_set_lowest>:
   0:	4a07      	ldr	r2, [pc, #28]	; (20 <pm_set_lowest+0x20>)
   2:	b508      	push	{r3, lr}
   4:	6913      	ldr	r3, [r2, #16]
   6:	f023 0304 	bic.w	r3, r3, #4
   a:	6113      	str	r3, [r2, #16]
   c:	f7ff fffe 	bl	0 <irq_disable>
  10:	f3bf 8f4f 	dsb	sy
  14:	bf30      	wfi
  16:	e8bd 4008 	ldmia.w	sp!, {r3, lr}
  1a:	f7ff bffe 	b.w	0 <irq_restore>
  1e:	bf00      	nop
  20:	e000ed00 	.word	0xe000ed00
```

With `__NOP();` after `__WFI();` (works):

```asm
00000000 <pm_set_lowest>:
   0:	4a07      	ldr	r2, [pc, #28]	; (20 <pm_set_lowest+0x20>)
   2:	b508      	push	{r3, lr}
   4:	6913      	ldr	r3, [r2, #16]
   6:	f023 0304 	bic.w	r3, r3, #4
   a:	6113      	str	r3, [r2, #16]
   c:	f7ff fffe 	bl	0 <irq_disable>
  10:	f3bf 8f4f 	dsb	sy
  14:	bf30      	wfi
  16:	bf00      	nop
  18:	e8bd 4008 	ldmia.w	sp!, {r3, lr}
  1c:	f7ff bffe 	b.w	0 <irq_restore>
  20:	e000ed00 	.word	0xe000ed00
```

With `volatile unsigned state;` (works):

```asm
00000000 <pm_set_lowest>:
   0:	b507      	push	{r0, r1, r2, lr}
   2:	4a08      	ldr	r2, [pc, #32]	; (24 <pm_set_lowest+0x24>)
   4:	6913      	ldr	r3, [r2, #16]
   6:	f023 0304 	bic.w	r3, r3, #4
   a:	6113      	str	r3, [r2, #16]
   c:	f7ff fffe 	bl	0 <irq_disable>
  10:	9001      	str	r0, [sp, #4]
  12:	f3bf 8f4f 	dsb	sy
  16:	bf30      	wfi
  18:	9801      	ldr	r0, [sp, #4]
  1a:	b003      	add	sp, #12
  1c:	f85d eb04 	ldr.w	lr, [sp], #4
  20:	f7ff bffe 	b.w	0 <irq_restore>
  24:	e000ed00 	.word	0xe000ed00
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/8518#issuecomment-363480519
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20180206/eff86ea8/attachment-0001.html>


More information about the notifications mailing list