# R-01 library for small OS

**URL:** <https://forum.clockworkpi.com/t/r-01-library-for-small-os/15602>\
**Category:** uConsole\
**Tags:** hardware, devterm, r-01, uconsole, baremetal\
**Created:** [February 3, 2025, 12:04pm UTC](https://forum.clockworkpi.com/t/r-01-library-for-small-os/15602 "2025-02-03T12:04:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylyamin](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/ylyamin/32/8418_2.png) [@ylyamin](https://forum.clockworkpi.com/u/ylyamin)\
**Post date:** [February 3, 2025, 12:04pm UTC](https://forum.clockworkpi.com/t/r-01-library-for-small-os/15602/1 "2025-02-03T12:04:15Z")

</div>

Hi all,

I created [bare-metal library for R-01](https://github.com/ylyamin/allwinner_d1_hal) (for [Allwinner D1H RISC-V SOC](https://d1.docs.aw-ol.com/en/)).  
Tested in [ClockworkPi DevTerm R-01](https://www.clockworkpi.com/home-devterm), should work in uConsole R-01 too.  
Everything actually is based on @robots [allwinner\_t113](https://github.com/robots/allwinner_t113) and @ua1arn [hftrx](https://github.com/ua1arn/hftrx) projects, these guys are genius.

Is minimal low-level library could be used to run own OS, or Doom or whatever.

Now is have:

- Bootloader, could run from SD card.
- USB keyboard working well
- TWI (I2C) supported AXP228 Power management chip for Display backlight and USB power.
- UART, GPIO

To run need configure UART adapter to 115200 baud rate.  
Insert flashed SD card to device should see output like this:

```auto
[INF]: \ | /
[INF]: - Allwinner D1 HAL [ver: 0.0.1-5-gd69c9f1]
[INF]: / | \
[INF]: SoC: D1H
[INF]: Platform: ClockworkPi Devterm R-01
[DBG]:irq_init
[DBG]:twi_init

```

With Display I have a big problem is work with [external board](https://wiki.sipeed.com/hardware/en/lichee/RV/Dock.html) with LCD RGB(ST7701S SPI) but with ClockworkPi LCD MIPI not work.  
My dream to have just one [C file](https://github.com/ylyamin/allwinner_d1_hal/blob/main/src/aw_lib/tcon_lcd.c) to init LCD and framebuffer, but LCD driver stack is very complicated.

I found drivers in [Linux](https://github.com/cuu/last_linux-5.4/tree/master/drivers/video/fbdev/sunxi/disp2/disp/de) and [RT-Thread OS](https://github.com/ylyamin/RT-Thread-on-Allwinner-D1H/blob/master/documentation/rt-thread/bsp/allwinner/libraries/sunxi-hal/hal/source/disp2) but is very big and I could not extract from it what should be set.  
Tried configure registers the same as in Linux but is still not work.

_Perhaps someone would enjoy diving deep into the LCD world to solve this riddle. Ready for issue reports and pull requests!_

Also I accumulated many knowledge and write [articles](https://github.com/ylyamin/RT-Thread-on-Allwinner-D1H/blob/master/documentation/D1_5_lcd_driver.md) when run [RT-Thread OS](https://github.com/ylyamin/RT-Thread-on-Allwinner-D1H) in DevTerm/uConsole R-01, in this OS LCD and USB work well.
