QEMU emulator version 5.1.0
stm32 code:
#include
#include
#include
extern void SER_Init(void);
static __IO uint32_t TimingDelay;
void Delay(__IO uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
void SysTick_Handler( void )
{
if( TimingDelay != 0x00 ){
TimingDelay--;
}
}
int init_system_tick( void )
{
printf( "SystemCoreClock = %d\n", SystemCoreClock );
if( SysTick_Config(SystemCoreClock / 1000) ){
printf("SysTick_Config fail!!!\n");
return -1;
}
return 0x00;
}
int main( void )
{
const char *a = "Hello world!";
char b[20];
char input_char;
SER_Init();
printf("test a shell src code...\n");
init_system_tick();
while( 1 ){
Delay(1000);
printf("in tick!!!\n");
}
//start_edit();
while(1){
//input_char = getchar();
//printf("input char = %x\n", input_char);
}
return 0;
}
keil4.72.0.0 设置输出 bin asm
#K\ARM\ARMCC\bin\fromelf.exe --bin -o #L.bin #L
#K\ARM\ARMCC\bin\fromelf.exe --text -c -o "[email protected]" "#L"
运行指令:
../../fuck_mips/qemu5p1/qemu-5.1.0/arm-softmmu/qemu-system-arm -M netduino2 -kernel Hello.axf.bin -nographic
[email protected]:nvic_sysreg_write NVIC sysreg write addr 0xd08 data 0x8000000 size 4
test a shell src code...
SystemCoreClock = 72000000
[email protected]:nvic_sysreg_write NVIC sysreg write addr 0xd23 data 0xf0 size 1
in tick!!!
in tick!!!
in tick!!!
in tick!!!
in tick!!!
ctrl+a x
quit
附加说明:qemu修改点:
static const uint32_t usart_addrxx[STM_NUM_USARTS] = { 0x40011000, 0x40004400,
0x40004800, 0x40004C00, 0x40005000, 0x40011400 };
static const uint32_t usart_addr[STM_NUM_USARTS] = { 0x40013800, 0x40004400,
0x40004800, 0x40004C00, 0x40005000, 0x40011400 };
in file --> hw/arm/stm32f205_soc.c
因为keil中的代码模拟的是stm32f103,其串口的基地址为 0x40013800,需要修改
其实就是用 103的bin文件,qemu用的模拟器是205的。system tick属于芯片核里面的,估计寄存器地址一样。实际效果是出来了。