# Bare metal development on uConsole R-01?

**URL:** <https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050>\
**Category:** uConsole\
**Created:** [January 4, 2024, 11:39pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050 "2024-01-04T23:39:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![anxietism](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/anxietism/32/8760_2.png) [@anxietism](https://forum.clockworkpi.com/u/anxietism)\
**Post date:** [January 4, 2024, 11:39pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/1 "2024-01-04T23:39:52Z")

</div>

Finally received and assembled my uConsole R-01 and Im quite happy with i!t It feels solid and handles surprisingly well. The ubuntu based distro is slow on the RISC-V soc, although the well laid out keyboard and trackball + the WiFi and crisp screen makes it decently usable. Too bad there is a single dead pixel!

Id like to experiment with bare metal programming to just side step the OS altogether but its not exactly clear to me how you can run custom boot code without using an existing linux image. I found this page that provides infos and manuals for the SoC used in the R-01 board [https://linux-sunxi.org/D1](https://linux-sunxi.org/D1) but neither the page dedicated to the board nor the github repo provide infos on the boot process as far as i can tell.

---

<div class="post-metadata">

**Author:** ![poetaster](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/poetaster/32/8558_2.png) [@poetaster](https://forum.clockworkpi.com/u/poetaster)\
**Post date:** [January 9, 2024, 6:28pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/2 "2024-01-09T18:28:13Z")

</div>

I run a bare metal DX 7 clone, MiniDexed, on a old pi , bare metal: [GitHub - probonopd/MiniDexed: Dexed FM synthesizer similar to 8x DX7 (TX816/TX802) running on a bare metal Raspberry Pi (without a Linux kernel or operating system)](https://github.com/probonopd/MiniDexed) It uses circle (and circle-stdlib) [GitHub - rsta2/circle: A C++ bare metal environment for Raspberry Pi with USB (32 and 64 bit)](https://github.com/rsta2/circle) But I’ve only used it for re-using old raspis. AND, I’m not sure about the rockchip.

---

<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:** [January 12, 2024, 6:56am UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/3 "2024-01-12T06:56:11Z")

</div>

Hi @anxietism,

I am also interested to dip dive to baremetal for RISC-V. Unfortunately, I still waiting for shipping but at this time I ordered Sipeed Lichee RV board with the same D1 MCU and successfully build Debian by this very good manual [Building boot software and Debian from sources for a RISC-V board (Sipeed Lichee RV with D1 processor) - Andreas' website](https://andreas.welcomes-you.com/boot-sw-debian-risc-v-lichee-rv/) (for U-Boot I use d1-2022-04-05 branch).  
This manual uses 5.17.0-rc2 kernel, next step for me figure out how to build more newest kernel.  
Also this page good illustrated boot process ttps://fedoraproject.org/wiki/Architectures/RISC-V/Allwinner

---

<div class="post-metadata">

**Author:** ![anxietism](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/anxietism/32/8760_2.png) [@anxietism](https://forum.clockworkpi.com/u/anxietism)\
**Post date:** [January 12, 2024, 7:57pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/4 "2024-01-12T19:57:31Z")

</div>

> I run a bare metal DX 7 clone, MiniDexed, on a old pi …

These are very cool projects but they seem to be very raspi/ARM specific. Still the circle is particularly interesting and most of the code seem to be portable.

> I am also interested to dip dive to baremetal for RISC-V. Unfortunately, I still waiting for shipping but at this time I ordered Sipeed Lichee RV…

Thanks @ylyamin this is very valuable info, i ll try to replicate this on the R-01 when i get some spare time. Hopefully the boot process on the R-01 is identical.

---

<div class="post-metadata">

**Author:** ![kallisti5](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/kallisti5/32/8062_2.png) [@kallisti5](https://forum.clockworkpi.com/u/kallisti5)\
**Post date:** [January 17, 2024, 2:19pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/5 "2024-01-17T14:19:56Z")

</div>

Since I like to shove Haiku on weird devices, here’s my initial research results:

Looking at the Ubuntu distro on the SD card… it looks like:

[Boot ROM (check GPIO pins) → MMC](https://github.com/DongshanPI/Awesome_RISCV-AllwinnerD1/blob/master/Tina-SDK/Hardware%E7%A1%AC%E4%BB%B6%E7%B1%BB%E6%96%87%E6%A1%A3/%E8%8A%AF%E7%89%87%E6%89%8B%E5%86%8C/D1-H_User%20Manual_V1.0.pdf) → u-boot → UEFI grub → Linux .

- u-boot spl is likely written to a fixed offset on the MicroSD card
  - source: The first partition starts at 69632… which generally means something is written to the raw microSD card before the first partition. It’s a common design model with Chinese SoC manufacturers (especially sunxi ones).
  - This makes it a pain in the a\*\* to make “generic” arm/riscv64 operating system images since each one has to be custom tailored for the device.
  - An offset of 8192 seems likely looking at other Allwinner devices. (unverified)

- uEnv.txt in /boot instructs u-boot to boot the Ubuntu UEFI loader
- The Ubuntu riscv64 UEFI bootloader is on /dev/mmcblk0p2 (/EFI/…) and should be mounted to /boot/efi on the running system (sudo mount /dev/mmcblk0p2 /boot/efi)

Unknowns:

- Unsure if there’s a built-in flash device with a embedded u-boot loader in addition to what’s on the microSD card.
- **Unknown u-boot source code location**
  - All I see is [GitHub - clockworkpi/bootloader: bootloader of clockworkpi](https://github.com/clockworkpi/bootloader) which is… empty.
  - Nothing in upstream u-boot.
  - EDIT: a WIP version appears to be here? [GitHub - smaeul/u-boot at d1-wip](https://github.com/smaeul/u-boot/tree/d1-wip)

**ClockworkPi needs to link to their u-boot source code… otherwise they’re in violation of the GPL.**

---

<div class="post-metadata">

**Author:** ![eleix](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/eleix/32/8436_2.png) [@eleix](https://forum.clockworkpi.com/u/eleix)\
**Post date:** [January 17, 2024, 3:57pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/6 "2024-01-17T15:57:23Z")

</div>

Yeah noticing the same thing here.

I have a uConsole on hand that I was working towards getting a custom os image loaded onto the device and I’m hitting a roadblock because I can’t tell what has been upstreamed and what is relying on some clever patchwork.

Going to need that u-boot code or otherwise this entire endeavor may be over before it even started.

---

<div class="post-metadata">

**Author:** ![kallisti5](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/kallisti5/32/8062_2.png) [@kallisti5](https://forum.clockworkpi.com/u/kallisti5)\
**Post date:** [January 17, 2024, 5:02pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/7 "2024-01-17T17:02:35Z")

</div>

Booting the uConsole without an SD card inserted results in the USB-C interface showing a “Allwinner Technology sunxi SoC OTG connector in FEL/flashing mode” interface.

[https://linux-sunxi.org/FEL](https://linux-sunxi.org/FEL)

So… that seems to confirm no built-in u-boot, it’s only on the sdcard.

```auto
$ ./sunxi-fel ver
AWUSBFEX soc=00001859(R528) 00000001 ver=0001 44 08 scratchpad=00005000 00000000 00000000
$ ./sunxi-fel spiflash-info
SPI support not implemented yet for 1859 (R528)!

```

---

<div class="post-metadata">

**Author:** ![kallisti5](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/kallisti5/32/8062_2.png) [@kallisti5](https://forum.clockworkpi.com/u/kallisti5)\
**Post date:** [January 17, 2024, 5:11pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/8 "2024-01-17T17:11:50Z")

</div>

oop. I think I found the u-boot sources for the uConsole…

[https://linux-sunxi.org/ClockworkPi\_R01](https://linux-sunxi.org/ClockworkPi_R01)

mentions:

> **[GitHub - smaeul/u-boot at d1-wip](https://github.com/smaeul/u-boot/tree/d1-wip)**
>
> d1-wip

Clockwork really needs to better document this.

---

<div class="post-metadata">

**Author:** ![kallisti5](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/kallisti5/32/8062_2.png) [@kallisti5](https://forum.clockworkpi.com/u/kallisti5)\
**Post date:** [January 17, 2024, 5:53pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/9 "2024-01-17T17:53:19Z")

</div>

One final observation… the 40 “GPIOS” on the Clockwork Mainboard 3.14 v5 are wired up exactly like a Rasbperry Pi. That would mean (in theory) the Raspberry Pi uart would be GPIO 14 / 15. (pin 8/10).

There could be serial uart on those pins if they were shooting to be “Raspberry Pi like” with the R-01. I can’t find any documentation on how to get to a serial uart on the uConsole… so some documentation improvements here would be nice.,

---

<div class="post-metadata">

**Author:** ![anxietism](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/anxietism/32/8760_2.png) [@anxietism](https://forum.clockworkpi.com/u/anxietism)\
**Post date:** [January 17, 2024, 6:04pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/10 "2024-01-17T18:04:00Z")

</div>

thanks for the replies, very interesting stuff, seems like getting some custom code to boot should be doable.

---

<div class="post-metadata">

**Author:** ![kallisti5](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/kallisti5/32/8062_2.png) [@kallisti5](https://forum.clockworkpi.com/u/kallisti5)\
**Post date:** [January 17, 2024, 6:09pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/11 "2024-01-17T18:09:40Z")

</div>

The irony is generally the most difficult part is figuring out the special secret sauce to get the SoC bootstrapped and code loaded. Everything else is pretty easy.

I was really hopeful that it would become standard to have a built-in u-boot “bios” on riscv64 devices.

Then operating system developers could just pack an EFI loader onto a microSD card and make generic / portable images. (u-boot includes a binary device tree and passes it to UEFI boot-loaders, so the OS media _technically_ doesn’t need hardware specific info besides drivers)

Allwinner seems to be continuing their bad habits from ARM though and allowing implementation partners to ship devices with no onboard flash rom’s.

---

<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:** [October 17, 2024, 6:59pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/12 "2024-10-17T18:59:30Z")

</div>

> [@R-01 RISC-V Baremetal with RT-Thread. LCD work, USB in progress](https://forum.clockworkpi.com/t/r-01-risc-v-baremetal-with-rt-thread-lcd-work-usb-in-progress/14683):
>
> Hi all, I successfully build and ran RT-Thread (a small embedded OS) on the Devterm R-01. It may also work in uConsole R-01, but I didn’t have uConsole. I would appreciate if someone could test it. Honestly, R-01 RISC-V core Allwinner D1H is really pain - documentation very limited regarding peripherals, there are no examples and no standalone libraries. However, if you enjoy brainteasers and some low-level stuff, you’re welcome. The intention was to make an RT-Thread portable terminal with…

---

<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:33pm UTC](https://forum.clockworkpi.com/t/bare-metal-development-on-uconsole-r-01/12050/13 "2025-02-03T12:33:15Z")

</div>

> [@R-01 library for small OS](https://forum.clockworkpi.com/t/r-01-library-for-small-os/15602):
>
> 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. …
