Skip to content

Commit db51f9c

Browse files
authored
Merge pull request #166 from f9micro/qemu-upstream
QEMU Upstream
2 parents bc1644c + a4aecb1 commit db51f9c

File tree

46 files changed

+1087
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1087
-286
lines changed

.github/workflows/build.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
board: [discoveryf4, discoveryf429, netduinoplus2]
15+
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Install ARM toolchain
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y gcc-arm-none-eabi
23+
24+
- name: Configure for ${{ matrix.board }}
25+
run: make ${{ matrix.board }}_defconfig
26+
27+
- name: Build kernel
28+
run: make
29+
30+
- name: Show binary size
31+
run: arm-none-eabi-size build/${{ matrix.board }}/f9.elf
32+
33+
- name: Upload artifacts
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: f9-${{ matrix.board }}
37+
path: |
38+
build/${{ matrix.board }}/f9.elf
39+
build/${{ matrix.board }}/f9.bin
40+
41+
qemu-test:
42+
runs-on: ubuntu-latest
43+
needs: build
44+
45+
steps:
46+
- uses: actions/checkout@v6
47+
48+
- name: Download netduinoplus2 artifact
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: f9-netduinoplus2
52+
path: build/netduinoplus2
53+
54+
- name: Install QEMU
55+
run: |
56+
sudo apt-get update
57+
sudo apt-get install -y qemu-system-arm
58+
59+
- name: QEMU boot test
60+
run: |
61+
timeout 15s qemu-system-arm \
62+
-M netduinoplus2 \
63+
-nographic \
64+
-serial mon:stdio \
65+
-kernel build/netduinoplus2/f9.elf 2>&1 | tee qemu.log || true
66+
67+
echo "=== QEMU Output ==="
68+
cat qemu.log
69+
echo "==================="
70+
71+
# Check for successful boot indicators
72+
if grep -q "Press '?' to print KDB menu" qemu.log; then
73+
echo "✓ KDB shell ready"
74+
exit 0
75+
elif grep -q "KDB" qemu.log; then
76+
echo "✓ KDB initialized"
77+
exit 0
78+
elif grep -q "f9" qemu.log || grep -q "F9" qemu.log; then
79+
echo "✓ Kernel boot detected"
80+
exit 0
81+
fi
82+
83+
# Check for crash indicators
84+
if grep -q "MEMFAULT\|HardFault\|panic" qemu.log; then
85+
echo "✗ Kernel crash detected"
86+
exit 1
87+
fi
88+
89+
echo "⚠ No boot message detected (timeout or minimal output)"
90+
exit 0

.travis.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ endif
1616

1717
ifeq "$(CONFIG_BOARD_STM32F429DISCOVERY)" "y"
1818
BOARD ?= discoveryf429
19-
else ifeq "$(CONFIG_BOARD_STM32P103)" "y"
20-
BOARD ?= stm32p103
19+
else ifeq "$(CONFIG_BOARD_NETDUINOPLUS2)" "y"
20+
BOARD ?= netduinoplus2
2121
else
2222
BOARD ?= discoveryf4
2323
endif
@@ -30,9 +30,9 @@ out ?= build/$(BOARD)
3030
# output directory for host build targets
3131
out_host ?= build/host
3232

33-
# FIXME: use smarter way to detect QEMU
34-
# qemu directory location
35-
QEMU_DIR ?= ../qemu_stm32/arm-softmmu/
33+
# QEMU command for netduinoplus2 emulation
34+
# Usage: qemu-system-arm -M netduinoplus2 -nographic -kernel build/netduinoplus2/f9.elf
35+
QEMU ?= qemu-system-arm
3636

3737
includes-user = user/include
3838
# toolchain specific configurations; common cflags and ldflags

board/Kconfig

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,26 @@ config BOARD_STM32F429DISCOVERY
2222
help
2323
STM32F429 Discovery board with STM32F429ZIT6 MCU and LCD.
2424

25-
config BOARD_STM32P103
26-
bool "Olimex STM32-P103"
27-
select PLATFORM_STM32F1
25+
config BOARD_NETDUINOPLUS2
26+
bool "Netduino Plus 2"
27+
select PLATFORM_STM32F4
2828
help
29-
Olimex STM32-P103 board with STM32F103RBT6 MCU.
29+
Netduino Plus 2 board with STM32F405RGT6 MCU.
30+
This board is supported by upstream QEMU for emulation.
3031

3132
endchoice
3233

34+
config QEMU
35+
bool "QEMU emulation mode"
36+
default y if BOARD_NETDUINOPLUS2
37+
help
38+
Enable workarounds for QEMU emulation limitations:
39+
- Use synchronous UART output (QEMU TXE interrupt unreliable)
40+
- Place bitmaps in regular SRAM (QEMU lacks CCM RAM emulation)
41+
42+
Enable this when running under QEMU. Disable for real hardware
43+
to get better performance.
44+
3345
endmenu
3446

3547
# Platform symbols (selected by board choice)
@@ -38,6 +50,3 @@ config PLATFORM_STM32F4
3850

3951
config PLATFORM_STM32F429
4052
bool
41-
42-
config PLATFORM_STM32F1
43-
bool

board/discoveryf4/defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
CONFIG_BOARD_STM32F4DISCOVERY=y
1010
# CONFIG_BOARD_STM32F429DISCOVERY is not set
11-
# CONFIG_BOARD_STM32P103 is not set
11+
# CONFIG_BOARD_NETDUINOPLUS2 is not set
1212
# CONFIG_BITMAP_BITBAND is not set
1313
# CONFIG_FPU is not set
1414
# CONFIG_STDIO_NODEV is not set

board/discoveryf429/defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
# CONFIG_BOARD_STM32F4DISCOVERY is not set
1010
CONFIG_BOARD_STM32F429DISCOVERY=y
11-
# CONFIG_BOARD_STM32P103 is not set
11+
# CONFIG_BOARD_NETDUINOPLUS2 is not set
1212
# CONFIG_BITMAP_BITBAND is not set
1313
# CONFIG_FPU is not set
1414
# CONFIG_STDIO_NODEV is not set
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,30 @@
33
* found in the LICENSE file.
44
*/
55

6-
#include <platform/stm32f1/gpio.h>
7-
#include <platform/stm32f1/usart.h>
6+
#include <platform/stm32f4/gpio.h>
7+
#include <platform/stm32f4/usart.h>
88
#include "board.h"
99

1010
struct usart_dev console_uart = {
11-
.u_num = 3,
11+
.u_num = 2,
1212
.baud = 115200,
1313
BOARD_USART_CONFIGS
1414
.tx = {
1515
.port = BOARD_USART_TX_IO_PORT,
1616
.pin = BOARD_USART_TX_IO_PIN,
17-
.mode = GPIO_MODE_OUT_ALT_PP,
17+
.pupd = GPIO_PUPDR_NONE,
18+
.type = GPIO_MODER_ALT,
1819
.func = BOARD_USART_FUNC,
19-
.ospeed = GPIO_OSPEED_50M,
20+
.o_type = GPIO_OTYPER_PP,
21+
.speed = GPIO_OSPEEDR_50M,
2022
},
2123
.rx = {
2224
.port = BOARD_USART_RX_IO_PORT,
2325
.pin = BOARD_USART_RX_IO_PIN,
24-
.mode = GPIO_MODE_OUT_ALT_PP,
26+
.pupd = GPIO_PUPDR_NONE,
27+
.type = GPIO_MODER_ALT,
2528
.func = BOARD_USART_FUNC,
26-
.ospeed = GPIO_OSPEED_50M,
29+
.o_type = GPIO_OTYPER_PP,
30+
.speed = GPIO_OSPEEDR_50M,
2731
},
2832
};
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* found in the LICENSE file.
44
*/
55

6-
#ifndef STM32P103_BOARD_H_
7-
#define STM32P103_BOARD_H_
6+
#ifndef NETDUINOPLUS2_BOARD_H_
7+
#define NETDUINOPLUS2_BOARD_H_
88

9-
#include <platform/stm32f1/registers.h>
10-
#include <platform/stm32f1/gpio.h>
11-
#include <platform/stm32f1/usart.h>
12-
#include <platform/stm32f1/nvic.h>
13-
#include <platform/stm32f1/systick.h>
9+
#include <platform/stm32f4/registers.h>
10+
#include <platform/stm32f4/gpio.h>
11+
#include <platform/stm32f4/usart.h>
12+
#include <platform/stm32f4/nvic.h>
13+
#include <platform/stm32f4/systick.h>
1414

1515
extern struct usart_dev console_uart;
1616

@@ -28,8 +28,25 @@ extern struct usart_dev console_uart;
2828
#define BOARD_USART_RX_IO_PORT GPIOA
2929
#define BOARD_USART_RX_IO_PIN 10
3030

31+
#elif defined(CONFIG_DBGPORT_USE_USART4)
3132

32-
#elif defined(CONFIG_DBGPORT_USE_USART2)
33+
#define BOARD_UART_DEVICE UART4_IRQn
34+
#define BOARD_UART_HANDLER UART4_HANDLER
35+
#define BOARD_USART_FUNC af_uart4
36+
#define BOARD_USART_CONFIGS \
37+
.base = UART4_BASE, \
38+
.rcc_apbenr = RCC_UART4_APBENR, \
39+
.rcc_reset = RCC_APB1RSTR_USART4RST,
40+
#define BOARD_USART_TX_IO_PORT GPIOA
41+
#define BOARD_USART_TX_IO_PIN 0
42+
#define BOARD_USART_RX_IO_PORT GPIOA
43+
#define BOARD_USART_RX_IO_PIN 1
44+
45+
#else /* default: USART2 */
46+
/* CONFIG_DBGPORT_USE_USART2
47+
* Note: QEMU routes USART1 to the console by default.
48+
* Use CONFIG_DBGPORT_USE_USART1 for QEMU emulation.
49+
*/
3350

3451
#define BOARD_UART_DEVICE USART2_IRQn
3552
#define BOARD_UART_HANDLER USART2_HANDLER
@@ -43,21 +60,6 @@ extern struct usart_dev console_uart;
4360
#define BOARD_USART_RX_IO_PORT GPIOA
4461
#define BOARD_USART_RX_IO_PIN 3
4562

46-
#else /* default: USART3 */
47-
/* CONFIG_DBGPORT_USE_USART3 */
48-
49-
#define BOARD_UART_DEVICE USART3_IRQn
50-
#define BOARD_UART_HANDLER USART3_HANDLER
51-
#define BOARD_USART_FUNC 0
52-
#define BOARD_USART_CONFIGS \
53-
.base = USART3_BASE, \
54-
.rcc_apbenr = RCC_USART3_APBENR, \
55-
.rcc_reset = RCC_APB1RSTR_USART3RST,
56-
#define BOARD_USART_TX_IO_PORT GPIOB
57-
#define BOARD_USART_TX_IO_PIN 10
58-
#define BOARD_USART_RX_IO_PORT GPIOB
59-
#define BOARD_USART_RX_IO_PIN 11
60-
6163
#endif
6264

63-
#endif /* STM32P103_BOARD_H_ */
65+
#endif /* NETDUINOPLUS2_BOARD_H_ */
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Copyright (c) 2014 The F9 Microkernel Project. All rights reserved.
1+
# Copyright (c) 2013 The F9 Microkernel Project. All rights reserved.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
CHIP := stm32f1
5+
CHIP := stm32f4
66
PLATFORM := stm32
7-
STM32_VARIANT := f1
7+
STM32_VARIANT := f4
88

99
board-y = board.o
1010
loader-board-y = board.loader.o

0 commit comments

Comments
 (0)