asm volatile (
/* disable interrupts, set mode */
"mrs r0, cpsr \n"
"bic r0, r0, #0x1f \n"
"orr r0, r0, #0xd3 \n"
"msr cpsr, r0 \n"

/* disable cache */
"ldr r0, =0xefff0000 \n"
"ldrh r1, [r0] \n"
"strh r1, [r0] \n"

/* unmap */
"mov r0, #0x18000000 \n"
"add r0, r0, #0x1c000 \n"
"mov r1, #0 \n"
"str r1, [r0, #4] \n"

/* setup stacks in iram */
"msr cpsr, #0xd2 \n"
"ldr r1, =0x18200274 \n"
"add r1, r1, #0x200 \n"
"mov sp, r1 \n"
"msr cpsr, #0xd3 \n"
"add r1, r1, #0x400 \n"
"mov sp, r1 \n"

/* jump into rom main() just before call to dfu mode */
"ldr r0, =0xec0 \n"
"bx r0 \n"
);