contributed by <ryanpatiency
>, <hexrabbit
>
The definitive guide to arm-cortex-m3 (book)
A book helps you understand the arm chip, including booting sequence, thumb mode vs arm mode, supervisor call (SVC)… .etc.
CSAPP (book)
Ch 7 & Ch 8.4.6 in book CSAPP to help you understand the principle behind objdump and readelf. As well as background knowledge about linker and loader
library 使用筆記1
這個人的教學很清楚,能幫助了解如何使用 library
library 使用筆記2
這個人的教學很清楚,能幫助了解如何使用 library
Bomb lab
To understand gdb and arm assembly
GNU linker script document
To understand hello.ld
semihosting
To learn background knowledge about module 00-Semihosting
stm32 程式開發
jserv 老師撰寫的筆記
沒辦法 compile/ build/ 燒錄(program)/ 執行 等等都沒有關係,先跳到程式碼閱讀和資料查詢的步驟,因為了解所有程式碼 e.g. Makefile, linker script, register file …和其背後的知識後,前面那些問題就自然解決了
screen 中輸入 enter 只有 '\r' 沒有 '\n'
STM32F429xx block diagram
在 datasheet 裡面找的到,對於判斷 那一個 peripheral 用那一個 clock 有幫助 (AHB, APB…)
I2C
可以幫助你了解 bus, master, slave 等是必備的知識
How to connect to stm32f429
(sudo) openocd -f board/stm32f429discovery.cfg \
-c "arm semihosting enable" \
-c "reset run"
// in another terminal
arm-none-eabi-gdb somewhere/f429disco.elf -ex "target remote:3333"
// use load in gdb to flash ROM
How to open UART: (Also see README.md in mini-arm-os)
// After connect PA9, PA10 to PC by TTL to USB
(sudo) screen /dev/ttyUSB0 115200 8n1
Note that Uart needs to have the same baud rate 115200
One don't need an extra usb-to-ttl line to talk with the board
by data sheet, the default st-link are connect to the usart1
malloc in 07-Threads is from the c programming language. it is really the pearl of programming
when interupt happens in the middle of:
So ARM hardwares will do these things (save & resume the status) for us,
and we don't need to bother considering it right?
HexRabbit
Right ryanpatiency
There is a document called "AAPCS", which means <Procedure Call Standard for the Arm Architecture> and has nothing to do with "APPCS"
.data section is fetched by system bus, instead of data bus. The range of D-Code bus have the same range with I-Code bus. As a result, the .data section put on 0x20000000 and above can only be fetched by system bus
03-context-switch2, the key point is r0 in context-switch.S
it, itt, ittt, itttt are all available. and t can be replaced with e, which means if then, if else, and which means it, ite, itet, itete are available as well.
qemu can be connected to gdb:
qemu-system-arm -M stm32-p103 -semihosting -nographic -kernel semi.bin -gdb tcp::1234 -S
gdb
with command target remote :1234
ENTRY(reset_handler)
is unnecessary since there is no os yet, and the reset_handler's trigger is because of its address location (byte 4)
the *
in *(.reset_headler)
is wildcard, before I think it is *ptr
uint32_t *isr_vectors[]
could be modified to uint32_t isr_vectors[]
, and the latter is more meaningful. (at least to me), or modify it a void *
since it holds pointer to stack, pointer to function, pointer to…etc
module semihosting
can be simulated, and one can use SYS_READ (0x06) for fun by qemu option -serial null -monitor null
, see semihosting and qemu
Change code to fit stm32-f4 according to reference manual
ex change RCC to 0x40023800 from 0x40021000
mini-arm-os study note
之前修課同學的共筆
Discovering the STM32 Microcontroller
Geoffrey Brown 的授課講義
openocd
燒程式的重要工具
fail to emulate rtenv+ with QEMU
gdb will fail tracing svc call in content_switch (but I've succeeded once..)
=> needs to set breakpoint in svc handler
In 04,06,07 there's a
stack += STACK_SIZE - 32; /* End of stack, minus what we are about to push */
but actually, we only need place (9+8) * sizeof(int) = 17 byte above the end of stack, so what does that 32 mean ?
=> just a large number
Is there any benefit of lr
register design in arm compared to intel's push
instruction with no need of a register to save return address ?
In 06-Preemptive, I think task_init()
is unnecessary, what is the meaning of calling svc 0
in privileged mode ?
Yes
task_init()
is unnecessary in this version, you could create a pull request.
ryanpatiency
sidata
means?UART
through the st-lint
to print hello world
. And How?as file_name.s -o a.out
is different from as file_name.s
ld
's default output is also a.out
, thus a conflictUART
in reference manual? and the rcc-enable in 01-helloworld, and all the hardware related things in 00 to 08ctrl-F "UART" in reference manual
and finish itdownload the CMSIS and search the keyword inside
svc_number = ((char*)PSP[6])[-2];
refers to SVC and <guide> ch9 p.146
800047c: df00 svc 0
800047e: 4770 bx lr
要注意到使用
[-2]
而不是[-1]
的原因是因為程式是運行在 little endian 環境且為 fixed-length instructions 架構下,所以實際上 .text 中真正的排列是00df
,這和一般 intel 的 variable-length instructions 架構下的排列不同
HexRabbit
-serial=null
work on qemu semihosting, (and what does it means?)__attribute
and __atribute__
-kernel
option, in qemu? its help: -kernel bzImage use 'bzImage' as kernel image
ENTRY
exactly do in link stage, I don't see any?main
, or _start
, and that is why when you didn't include a _start
symbol, it will say something like couldn't find _start, entry set at 0x4002800
lr
will be modified to an very large value, so what will happen when it returns(bx lr
) ?pc
and also lr
will be restored from stacknop
in syscall.S
? Is it used for optimization purpose?nop
was added because qemu
's bug, and qemu
might fix this bug already.