Skip to content

newluhux/qemu-mt7628

Repository files navigation

project move

new repo: https://github.com/newluhux/qemu-hui

qemu mt7628

I’m try add mt7628 support into qemu.

hardware support

hardwarestatustest result
DDR 256MiBOKuboot ok, linux ok, NetBSD 9.0 ok
SYSCTLOKuboot ok, linux ok, NetBSD 9.0 ok
INTCOKlinux ok, NetBSD 9.0 ok
TIMERTODO
MEMCTODO
UARTOKuboot ok, linux ok, NetBSD 9.0 ok
HSUARTTODO
I2CTODO
AUDIOTODO
GDMATODO
SPI MASTEROKuboot ok, linux ok
EHCIOKuboot ok, linux ok, NetBSD 9.0 ok
OHCIOKuboot ok, linux ok, NetBSD 9.0 ok
FLASH-DIRECTOKuboot ok
ETHERNETOKuboot ok, linux ok, NetBSD 9.0 ok
SDXCTODO
GPIOTODO
PCIETODO

boot from flash

You can boot from flash, but need skip ‘ddr_calibrate’:

Disassemble uboot.bin, find the location of the ddr_calibrate function, and then use hexedit to modify it so that it can skip ddr initialization (because qemu does not emulate it).

If you not skip ddr_calibrate, you will take a lot of time at memory test,

but uboot still can bootup, test on mainline uboot.

bootrom?

I can’t found it on real board.

I am going to write a simple bootrom to initialize the device, only use for qemu.

how to run it

  1. use buildroot build firmware: https://github.com/newluhux/vocore2/tree/master/buildroot

why use vocore2’s buildroot?:

I found ‘mt7628_evb’ in uboot source code, but I can’t found this board on taobao or ebay.

  1. get qemu source tree and apply patch
git clone https://gitlab.com/qemu-project/qemu /path/to/qemu
cd /path/to/qemu/
git am < xxxx.patch
  1. build qemu
cd /path/to/qemu/
./configure --cc=gcc --cxx=g   \
		--target-list=mipsel-softmmu \
		--enable-debug --enable-debug-tcg --enable-debug-info
make -j$(nproc)
make check
  1. run qemu:

because use ‘uboot.elf’.

you must select ‘CONFIG_REMAKE_ELF=y’ in uboot config file.

cd /path/to/qemu/
./qemu-system-mipsel -M mt7628 -m 128 \
               -nographic \
		-serial telnet:127.0.0.1:4000,server \
		-serial telnet:127.0.0.1:4001,server \
		-serial telnet:127.0.0.1:4002,server \
		-drive if=mtd,index=0,file=/path/to/buildroot/output/images/flash_16M.bin,format=raw \
		-object filter-dump,id=f1,netdev=hub0port0,file=dump.dat \
		-kernel /path/to/buildroot/output/build/u-boot-VERSION/uboot.elf \
		-s -S

connect to serial port:

telnet 127.0.0.1 4000 # UART0
telnet 127.0.0.1 4001 # UART1
telnet 127.0.0.1 4002 # UART2

look network traffic:

use wireshark open ‘dump.dat’

license

same with qemu

history

2022/01/06: UART output is working, input is not working, need impl irq.

2022/01/09: add unimp memory region mapping.

2022/01/14: add mt7628-intc, UART input is working. can use shell.

2022/01/15: upload missing code, fix intc, add mt7628 reset control, usb host is working.

2022/01/16: add flash direct access support. try add boot from flash support, but uboot is not working, need fix qemu to run unmodify uboot.

2022/01/18: try send patch to qemu upstream.

2022/01/21: uboot is wip, I need emulate a mt7628 DDR controler.

2022/01/23: write a ddr controler is boring, try impl spi master.

2022/01/25: spi master is ok, default attach a w25q128 flash, next is ethernet or pcie.

2022/01/28: spi master have bug, rewrite it, add chip select.

2022/01/30: uboot is working, you can use uboot to boot from flash.

2022/02/04: rewrite system control, merge vocore2 device to mt7628 device.

2022/02/13: write a ethernet emulate, uboot bootp can working.

2022/02/14: fix ethernet recive missing some packet, add ohci.

2022/02/15: spi control support two cs line.

2022/02/16: flash direct access is provide by spi controller.

2022/02/19: now, you can boot from flash, but need skip ddr_calibrate, please read source code, support bootrom.

2022/03/17: rewrite ethernet emulation, add interrupt support, network is pass on NetBSD 9.0

2023/03/30: my job is busy, haven’t time to test it, now mt7628’s ethernet can work on mainline openwrt.

2023/03/31: study i2c :), try impl i2c controller.

About

qemu mt7628 support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published