mini-arm-os of Tony
export PATH=~/workspace/qemu_stm32/arm-softmmu:$PATH
  • when can we use this?
  1. when you enable compiler optimizations
  1. interrupts are enabled
  1. flaky hardware drivers
  1. RTOS tasks that work fine in isolation--until some other task is spawned
  • It tells the compiler that the value of the variable may change at any time
volatile int foo; 
int volatile foo;
volatile uint8_t * pReg; 
uint8_t volatile * pReg;
  • proper use of volatile keyword
  1. Memory-mapped peripheral registersme
  1. Global variables modified by an interrupt service routine (ISR)
  1. Global variables accessed by multiple tasks within a multi-threaded application
  • shared global variables should be declared volatile!!
  • register keyword 
  • hints to compiler that a given variable can be put in a register
  • register operation is faster than memory
  • C inline assembly
  • __attribute
Linker Script 簡介 :GNU ld 
GNU ld 手冊略讀 :Manual
  • This is called bare-metal that the standard does not follow traditional OS ABI
  • 查表好好玩
  • 如果USART_DR傳送長度從 1 byte --> 4byte會發生什麼事?
  • 如此一來是否可以提高資料的傳送量?
  • 在context-switch02裡面,svc 0 代表了什麼意思呢?
  • 測試過把這個數字隨便亂改,結果好像都沒改變
__asm void SVCHandler(void){    
    IMPORT SVCHandler_main    
    TST lr, #4    
    MRSEQ r0, MSP    
    MRSNE r0, PSP    
    B SVCHandler_main