Skip to content

Commit

Permalink
Base Rockchip platfrom drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
GuEe-GUI committed Nov 9, 2023
1 parent 80d7885 commit 75a95d1
Show file tree
Hide file tree
Showing 319 changed files with 46,489 additions and 3,767 deletions.
92 changes: 63 additions & 29 deletions bsp/qemu-virt64-aarch64/.config
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CONFIG_RT_USING_MESSAGEQUEUE=y
# Memory Management
#
CONFIG_RT_PAGE_MAX_ORDER=11
# CONFIG_RT_USING_MEMPOOL is not set
CONFIG_RT_USING_MEMPOOL=y
# CONFIG_RT_USING_SMALL_MEM is not set
CONFIG_RT_USING_SLAB=y
CONFIG_RT_USING_MEMHEAP=y
Expand Down Expand Up @@ -174,6 +174,7 @@ CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
CONFIG_RT_USING_DFS_DEVFS=y
CONFIG_RT_USING_DFS_DIRECTFS=y
CONFIG_RT_USING_DFS_ROMFS=y
# CONFIG_RT_USING_DFS_CROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
Expand All @@ -192,30 +193,37 @@ CONFIG_RT_LWP_SHM_MAX_NR=64
#
# Device Drivers
#
CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_UNAMED_PIPE_NUMBER=64
CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=8192
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
CONFIG_RT_USING_TTY=y
# CONFIG_RT_TTY_DEBUG is not set
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PHY is not set
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_DAC is not set
CONFIG_RT_USING_NULL=y
CONFIG_RT_USING_ZERO=y
CONFIG_RT_USING_RANDOM=y
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_SENSOR is not set
# CONFIG_RT_USING_TOUCH is not set
# CONFIG_RT_USING_LCD is not set
# CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set
CONFIG_RT_USING_DEV_BUS=y
# CONFIG_RT_USING_WIFI is not set
CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_UNAMED_PIPE_NUMBER=64
CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=8192
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
# CONFIG_RT_USING_ADC is not set
CONFIG_RT_USING_AUDIO=y
CONFIG_RT_AUDIO_REPLAY_MP_BLOCK_SIZE=4096
CONFIG_RT_AUDIO_REPLAY_MP_BLOCK_COUNT=2
CONFIG_RT_AUDIO_RECORD_PIPE_SIZE=2048
CONFIG_RT_AUDIO_INTEL_HDA=y
# CONFIG_RT_AUDIO_ROCKCHIP is not set
# CONFIG_RT_USING_CAN is not set
CONFIG_RT_USING_CLK=y
# CONFIG_RT_CLK_ROCKCHIP is not set
CONFIG_RT_USING_FIRMWARE=y
CONFIG_RT_FIRMWARE_PSCI=y
CONFIG_RT_FIRMWARE_QEMU_FW_CFG=y
CONFIG_RT_USING_HWCRYPTO=y
CONFIG_RT_HWCRYPTO_DEFAULT_NAME="hwcryto"
CONFIG_RT_HWCRYPTO_IV_MAX_SIZE=16
Expand All @@ -231,26 +239,32 @@ CONFIG_RT_HWCRYPTO_KEYBIT_MAX_SIZE=256
CONFIG_RT_HWCRYPTO_USING_RNG=y
# CONFIG_RT_HWCRYPTO_USING_CRC is not set
# CONFIG_RT_HWCRYPTO_USING_BIGNUM is not set
# CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set
CONFIG_RT_USING_DEV_BUS=y
# CONFIG_RT_USING_WIFI is not set
CONFIG_RT_USING_CLK=y
CONFIG_RT_USING_FIRMWARE=y
CONFIG_RT_FIRMWARE_PSCI=y
# CONFIG_RT_HWCRYPTO_RNG_ROCKCHIP is not set
# CONFIG_RT_USING_HWSPINLOCK is not set
CONFIG_RT_USING_HWTIMER=y
CONFIG_RT_HWTIMER_ARM_ARCH=y
# CONFIG_RT_HWTIMER_RISCV_CLINT is not set
# CONFIG_RT_HWTIMER_BCM2835 is not set
# CONFIG_RT_HWTIMER_ROCKCHIP is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_MBOX is not set
# CONFIG_RT_USING_MFD is not set
# CONFIG_RT_USING_MTD_NAND is not set
CONFIG_RT_USING_MTD_NOR=y
CONFIG_RT_USING_MTD_NOR_CFI=y
CONFIG_RT_USING_OFW=y
# CONFIG_RT_USING_BUILTIN_FDT is not set
CONFIG_RT_FDT_EARLYCON_MSG_SIZE=128
CONFIG_RT_USING_OFW_DIRECTFS=y
CONFIG_RT_USING_PCI=y
CONFIG_RT_PCI_MSI=y
CONFIG_RT_PCI_SYS_64BIT=y
CONFIG_RT_PCI_CACHE_LINE_SIZE=8
# CONFIG_RT_PCI_LOCKLESS is not set
CONFIG_RT_PCI_ECAM=y
CONFIG_RT_PCI_HOST_COMMON=y
CONFIG_RT_PCI_HOST_GENERIC=y
# CONFIG_RT_PCI_DW_HOST is not set
# CONFIG_RT_USING_PHY is not set
CONFIG_RT_USING_PIC=y
CONFIG_MAX_HANDLERS=512
# CONFIG_RT_PIC_BCM2835_INTC is not set
Expand All @@ -260,36 +274,56 @@ CONFIG_RT_PIC_ARM_GIC=y
CONFIG_RT_PIC_ARM_GIC_V3=y
# CONFIG_RT_PIC_ARM_GIC_V3_ITS is not set
CONFIG_RT_PIC_ARM_GIC_MAX_NR=1
# CONFIG_RT_PIC_RISCV_INTC is not set
# CONFIG_RT_PIC_SIFIVE_PLIC is not set
CONFIG_RT_USING_PINCTRL=y
# CONFIG_RT_PINCTRL_ROCKCHIP is not set
CONFIG_RT_USING_PIN=y
CONFIG_RT_PIN_PL061=y
# CONFIG_RT_PIN_ROCKCHIP is not set
CONFIG_RT_USING_PM=y
CONFIG_PM_TICKLESS_THRESHOLD_TIME=2
# CONFIG_PM_USING_CUSTOM_CONFIG is not set
# CONFIG_PM_ENABLE_DEBUG is not set
# CONFIG_PM_ENABLE_SUSPEND_SLEEP_MODE is not set
# CONFIG_PM_ENABLE_THRESHOLD_SLEEP_MODE is not set
# CONFIG_RT_PM_RESET_SYSCON is not set
# CONFIG_RT_PM_RESET_SYSCON_POWEROFF is not set
# CONFIG_RT_PM_BCM2835 is not set
# CONFIG_RT_PM_SYSCON_POWEROFF is not set
# CONFIG_RT_PM_SYSCON_REBOOT is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_REGULATOR is not set
# CONFIG_RT_USING_RESET is not set
CONFIG_RT_USING_RTC=y
CONFIG_RT_USING_ALARM=y
# CONFIG_RT_USING_SOFT_RTC is not set
CONFIG_RT_RTC_PL031=y
# CONFIG_RT_RTC_GOLDFISH is not set
# CONFIG_RT_RTC_HYM8563 is not set
CONFIG_RT_RTC_PL031=y
# CONFIG_RT_RTC_RK_TIMER is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SENSOR is not set
CONFIG_RT_USING_SERIAL=y
CONFIG_RT_USING_SERIAL_V1=y
# CONFIG_RT_USING_SERIAL_V2 is not set
CONFIG_RT_SERIAL_USING_DMA=y
CONFIG_RT_SERIAL_RB_BUFSZ=256
CONFIG_RT_SERIAL_PL011=y
CONFIG_RT_SERIAL_8250=y
# CONFIG_RT_SERIAL_8250_BCM2835AUX is not set
# CONFIG_RT_SERIAL_8250_DW is not set
# CONFIG_RT_SERIAL_8250_OFW is not set
CONFIG_RT_SERIAL_8250_PCI=y
CONFIG_RT_USING_SOC=y
# CONFIG_RT_SOC_ROCKCHIP is not set
# CONFIG_RT_USING_SPI is not set
CONFIG_RT_USING_VIRTIO=y
CONFIG_RT_VIRTIO_TRANSPORT_MMIO=y
CONFIG_RT_VIRTIO_TRANSPORT_PCI=y
CONFIG_RT_VIRTIO_NET=y
CONFIG_RT_VIRTIO_BLK=y
CONFIG_RT_VIRTIO_CONSOLE=y
CONFIG_RT_VIRTIO_RNG=y
CONFIG_RT_VIRTIO_GPU=y
CONFIG_RT_VIRTIO_INPUT=y
# CONFIG_RT_USING_WDT is not set

#
# Using USB
Expand Down
10 changes: 9 additions & 1 deletion bsp/qemu-virt64-aarch64/applications/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@

int main(int argc, char** argv)
{
const char *oem;

#ifdef RT_USING_SMART
oem = "Smart";
#else
oem = "Thread";
#endif

rt_ubase_t level = rt_hw_interrupt_disable();

rt_kprintf("Hi, this is RT-Thread!!\n");
rt_kprintf("Hi, this is RT-%s!!\n", oem);

rt_hw_interrupt_enable(level);

Expand Down
12 changes: 5 additions & 7 deletions bsp/qemu-virt64-aarch64/applications/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#define LINUX_KEY_POWER 116 /* SC System Power Down */

void linux_key_poweroff(void *args)
static void linux_key_poweroff(void *args)
{
LOG_I("Power off the machine by [%s]", args);

Expand All @@ -39,9 +39,9 @@ static int pin_init()

rt_ofw_foreach_child_node(gpio_keys_np, key)
{
struct rt_ofw_cell_args args;
rt_base_t pin = rt_ofw_get_named_pin(key, "gpios", 0, RT_NULL, RT_NULL);

if (!rt_ofw_parse_phandle_cells(key, "gpios", "#gpio-cells", 0, &args))
if (pin >= 0)
{
rt_uint32_t linux_code;
void *key_args = RT_NULL;
Expand All @@ -61,11 +61,9 @@ static int pin_init()

if (fn_ptr)
{
rt_pin_attach_irq(args.args[0], args.args[1], fn_ptr, key_args);
rt_pin_irq_enable(args.args[0], RT_TRUE);
rt_pin_attach_irq(pin, PIN_IRQ_PIN_NONE, fn_ptr, key_args);
rt_pin_irq_enable(pin, RT_TRUE);
}

rt_ofw_node_put(args.data);
}
}

Expand Down
85 changes: 57 additions & 28 deletions bsp/qemu-virt64-aarch64/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
opt=sys.argv

graphic_cfg=""" \
-serial stdio \
-serial stdio -device ramfb \
-device virtio-gpu-device,xres=800,yres=600 \
-device virtio-keyboard-device \
-device virtio-mouse-device \
Expand All @@ -14,71 +14,100 @@

q_gic=2
q_dumpdtb=""
q_el=1
q_smp=4
q_mem=128
q_graphic="-nographic"
q_debug=""
q_bootargs="console=ttyAMA0 earlycon root=block0 rootfstype=elm"
q_bootargs="console=ttyAMA0 earlycon root=block0 rootfstype=elm rootwait rw"
q_initrd=""
q_sd="sd.bin"
q_net="user,id=net0"
q_flash="flash.bin"
q_nvme="nvme.bin"
q_emmc="emmc.bin"

def is_opt(key, inkey):
if str("-"+key) == inkey:
return True
return False

if sys.platform.startswith('win'):
if not os.path.exists(q_sd):
os.system("qemu-img create -f raw {} 64M".format(q_sd))
if not os.path.exists(q_flash):
os.system("qemu-img create -f raw {} 64M".format(q_flash))
else:
if not os.path.exists(q_sd):
os.system("dd if=/dev/zero of={} bs=1024 count=65536".format(q_sd))
if not os.path.exists(q_flash):
os.system("dd if=/dev/zero of={} bs=1024 count=65536".format(q_flash))

for i in range(len(opt)):
if i == 0:
continue
inkey=opt[i]

if is_opt("gic", inkey): q_gic = int(opt[i+1])
if is_opt("dumpdtb", inkey): q_dumpdtb = str(",dumpdtb=" + opt[i+1])
if is_opt("smp", inkey): q_smp = int(opt[i+1])
if is_opt("mem", inkey): q_mem = int(opt[i+1])
if is_opt("debug", inkey): q_debug = "-S -s"
if is_opt("bootargs", inkey): q_debug = opt[i+1]
if is_opt("graphic", inkey): q_graphic = graphic_cfg
if is_opt("sd", inkey): q_sd = opt[i+1]
if is_opt("flash", inkey): q_flash = opt[i+1]
if is_opt("gic", inkey): q_gic=int(opt[i+1])
if is_opt("dumpdtb", inkey): q_dumpdtb=str(",dumpdtb=" + opt[i+1])
if is_opt("el", inkey): q_el=int(opt[i+1])
if is_opt("smp", inkey): q_smp=int(opt[i+1])
if is_opt("mem", inkey): q_mem=int(opt[i+1])
if is_opt("debug", inkey): q_debug="-S -s"
if is_opt("bootargs", inkey): q_bootargs=opt[i+1]
if is_opt("initrd", inkey): q_initrd=str("-initrd " + opt[i+1])
if is_opt("graphic", inkey): q_graphic=graphic_cfg
if is_opt("sd", inkey): q_sd=opt[i+1]
if is_opt("tap", inkey): q_net="tap,id=net0,ifname=tap0"
if is_opt("flash", inkey): q_flash=opt[i+1]
if is_opt("nvme", inkey): q_nvme=opt[i+1]
if is_opt("emmc", inkey): q_emmc=opt[i+1]

if q_smp > 8:
q_gic = 3
q_gic=3

if q_el == 1:
q_el=""
elif q_el == 2:
q_el=",virtualization=on"
if q_gic == 3:
q_gic="max"
elif q_el == 3:
q_el=",secure=on"
else:
print("Invalid -el {}".format(q_el));
exit(0)

bin_list = [q_sd, q_flash, q_nvme, q_emmc]

if sys.platform.startswith('win'):
for bin in bin_list:
if not os.path.exists(bin):
os.system("qemu-img create -f raw {} 64M".format(bin))
else:
for bin in bin_list:
if not os.path.exists(bin):
os.system("dd if=/dev/zero of={} bs=1024 count=65536".format(bin))

os.system("""
qemu-system-aarch64 \
-M virt,gic-version={}{} \
-M virt,acpi=on,iommu=smmuv3,its=on,gic-version={}{}{} \
-cpu max \
-smp {} \
-m {} \
-kernel rtthread.bin \
-append "{}" \
{} \
{} \
{} \
-drive if=none,file={},format=raw,id=blk0 \
-device virtio-blk-device,drive=blk0 \
-netdev user,id=net0 \
-netdev {} \
-device virtio-net-device,netdev=net0 \
-device virtio-rng-device \
-device intel-hda \
-device hda-duplex \
-drive file={},format=raw,if=pflash,index=1 \
-drive file={},format=raw,if=none,id=nvme0 \
-device nvme,serial=deadbeef,drive=nvme0 \
-drive file={},format=raw,if=none,id=emmc0 \
-device sdhci-pci -device sd-card,drive=emmc0 \
-device virtio-serial-device \
-chardev socket,host=127.0.0.1,port=4321,server=on,wait=off,telnet=on,id=console0 \
-device virtserialport,chardev=console0
""".format(q_gic, q_dumpdtb, q_smp, q_mem, q_bootargs, q_graphic, q_debug, q_sd, q_flash))
-device virtserialport,chardev=console0 \
-device pci-serial,chardev=console1 \
-chardev socket,host=127.0.0.1,port=4322,server=on,wait=off,telnet=on,id=console1
""".format(q_gic, q_dumpdtb, q_el, q_smp, q_mem, q_bootargs, q_initrd, q_graphic, q_debug, q_sd, q_net, q_flash, q_nvme, q_emmc))

if len(q_dumpdtb) != 0:
dtb=q_dumpdtb.split('=')[-1]
os.system("dtc -I dtb -O dts {} -o {}".format(dtb, dtb.replace(".dtb", ".dts")))
os.system("dtc -I dtb -O dts -@ -A {} -o {}".format(dtb, dtb.replace(".dtb", ".dts")))
Loading

0 comments on commit 75a95d1

Please sign in to comment.