2019-05-04 13:10:52 +04:00
Maix Go / K210 stuff
=====================
2019-05-14 15:42:30 +04:00
Building the C projects
-----------------------
2019-05-04 13:10:52 +04:00
First, get the Kendryte C toolchain and copy or symlink the contents of the
`src/` folder to a checkout of `https://github.com/sipeed/LicheeDan_K210_examples.git` .
Then to build a certain project do:
```bash
mkdir build & & cd build
cmake .. -DPROJ=< ProjectName > -DTOOLCHAIN=/opt/riscv-toolchain/bin & & make
```
You will get 2 files, `build/<ProjectName>` and `build/<ProjectName>.bin` . The former
is an ELF executable, the latter a raw binary that can be flashed or written to
2019-05-27 14:24:48 +04:00
address `0x80000000` in SRAM and directly executed.
2019-05-04 13:10:52 +04:00
2019-05-14 15:42:30 +04:00
Building the Rust projects
--------------------------
2019-05-27 14:24:48 +04:00
**Note:** *it's possible that these projects require Rust nightly to build. I
don't intentially use nightly features, however, I always test only using the
latest one so it's likely that something will sneak in*
Make sure the appropriate target has been added to the toolchain that you wish
to use:
```bash
rustup target add riscv64gc-unknown-none-elf
```
2019-05-27 12:02:54 +04:00
2019-05-14 15:42:30 +04:00
Target configuration is set up in `.cargo/config` , so building is a matter of:
2019-05-27 14:24:48 +04:00
```bash
2019-05-14 15:42:30 +04:00
cd rust/< name_of_project >
cargo build --release
```
This will produce an ELF executable in the workspace's target directory named
`rust/target/riscv64gc-unknown-none-elf/release/<name_of_project>` .
2019-05-14 19:16:08 +04:00
If you have openocd working for the board, the below should work:
```
cargo run
```
Otherwise, see next section.
2019-05-14 15:42:30 +04:00
Running ELF
-----------
There is no need anymore to convert to raw binary, as ELF executables can be executed directly on
2019-05-27 14:24:48 +04:00
the device (no flashing) using a recent checkout of [kflash ](https://github.com/kendryte/kflash.py )
2019-05-14 15:42:30 +04:00
```bash
kflash.py -t -s -p /dev/ttyUSB1 -B goE "${ELF_NAME}"
```
This works for both the C and Rust-produced executables. It is also possible to upload
2019-05-14 19:16:08 +04:00
and run code on the device through JTAG and OpenOCD, but I have never got this to work myself
(openocd cannot find the device).
2019-05-14 15:42:30 +04:00
2019-05-27 14:24:48 +04:00
Currently, rust generates ELF executables based at address `0xffffffff80000000`
instead of the expected `0x80000000` , to work around lack of medany memory
model support in LLVM. To make this work with kflash I had to patch the
following:
```patch
diff --git a/kflash.py b/kflash.py
index c092d08..b3bc457 100755
--- a/kflash.py
+++ b/kflash.py
@@ -976,7 +976,7 @@ class KFlash:
if segment['p_type']!='PT_LOAD' or segment['p_filesz']==0 or segment['p_vaddr']==0:
print("Skipped")
continue
- self.flash_dataframe(segment.data(), segment['p_vaddr'])
+ self.flash_dataframe(segment.data(), segment['p_vaddr'] & 0xffffffff)
def flash_firmware(self, firmware_bin, aes_key = None, address_offset = 0, sha256Prefix = True):
# type: (bytes, bytes, int, bool) -> None
```
2019-05-04 13:21:52 +04:00
Documentation
==============
2019-05-04 13:37:38 +04:00
Additional register documentation that is not in the datasheet can be found here:
- [K210 memory map ](doc/memory_map.md ) - A rough memory map for the Kendryte K210 (as used on the Sipeed Maix boards)
2019-05-04 16:00:08 +04:00
- [OTP memory map ](doc/otp_layout.md ) - Some random notes about the layout of the Kendryte K210 OTP memory
2019-05-04 14:28:24 +04:00
- [LicheeDan / MaixGo on-board peripherals ](doc/onboard.md ) - List of on-board peripherals and chips for the various boards with a K210
External:
2019-05-04 13:37:38 +04:00
- [k210.svd ](https://github.com/riscv-rust/k210-pac/blob/master/k210.svd ) - Peripheral description for rust K210 BSP (k210-pac project)
2019-05-04 13:21:52 +04:00
2019-05-04 13:10:52 +04:00
Projects
=========
2019-05-14 15:42:30 +04:00
This is a general random sandbox with silly projects for me to play around with the Maix Go, some are in C and some are in Rust.
2019-06-02 01:00:26 +04:00
It turns out that this cheap board is great for playing around with Rust embedded in an environment that
has a fair amount of memory and number of peripherals available by default!
2019-05-14 15:42:30 +04:00
2019-05-04 13:10:52 +04:00
glyph_mapping
-------------
Variation of the `DVP` sample that processes the camera input through a simple
DOS 8× 8 font glyph-mapping algorithm and shows it on the display.
2019-05-04 13:14:46 +04:00
[README ](src/glyph_mapping/README.md )
2019-05-04 13:10:52 +04:00
dump_otp
--------
Dumps the contents of the OTP (One-Time Programmable memory) of the K210 CPU to
serial output in Intel HEX format.
2019-05-04 13:14:46 +04:00
[README ](src/dump_otp/README.md )
2019-05-04 15:07:58 +04:00
2019-05-13 03:42:42 +04:00
secp256k1\_{tests,bench}
------------------------
Run tests and benchmarks for the secp256k1 elliptic curve cryptographic library on this RISC-V CPU.
2019-05-14 19:12:54 +04:00
rust/accelerometer
-----------------
2019-05-14 21:09:32 +04:00
Read measurements from MSA300 accelerometer. Display a dot on the screen to visualize the current orientation
and magnitude.
2019-05-14 19:12:54 +04:00
[README ](rust/accelerometer/README.md )
2019-05-11 14:18:44 +04:00
rust/k210-console
-----------------
Console emulator written in Rust for the Maix Go.
Barely functional at the moment. This is really a test for some functionality
like SPI and driving the display from Rust, and for playing with Rust RISC-V 64
in general.
[README ](rust/k210-console/README.md )
2019-05-11 21:54:48 +04:00
rust/mandelbrot
---------------
Mandelbrot fractal zoom.
[README ](rust/mandelbrot/README.md )
2019-05-13 17:17:55 +04:00
rust/game-of-life
-----------------
"Game of life" cellular automata simulation. The state can be manipulated through the touch screen.
The amount of pressure applied determines the radius of the state change.
[README ](rust/game-of-life/README.md )
2019-05-20 17:49:43 +04:00
rust/uart-passthrough
---------------------
Pass through UART from host to the ESP8285 WIFI chip.
[README ](rust/uart-passthrough/README.md )
2019-05-23 13:22:50 +04:00
rust/rgbcontrol
----------------
Control the color of the RGB LED from the touch screen.
[README ](rust/rgbcontrol/README.md )
2019-05-26 19:00:09 +04:00
rust/esp8266at
--------------
A crate for communicating with WiFi using the ESP8266 using AT commands. TODO: move this to its own repository.
[README ](rust/esp8266at/README.md )
rust/weather
------------
Uses the ESP8285 WiFi chip of the Maix Go to fetch weather data from
[wttr.in ](https://wttr.in ) and print it to the display using `k210-console` .
[README ](rust/weather/README.md )
2019-06-02 01:00:26 +04:00
rust/dvp-ov
-----------
A straightforward passthrough test for video handling, based on `dvp_ov` in the
SDK: read frames from the OV2640 image sensor and display them on the LCD.
[README ](rust/dvp-ov/README.md )
2019-06-02 16:51:13 +04:00
rust/glyph-mapping
------------------
Rust port of the glyph mapping demo.
[README ](rust/glyph-mapping/README.md )
2019-05-05 07:25:26 +04:00
ROM re'ing
===========
Annotated radare2 config files for the Boot ROM and OTP can be found under [r2 ](r2/README.md ).
2019-05-04 15:07:58 +04:00
Other projects
==============
2019-05-13 03:42:42 +04:00
Some interesting K210-based projects and demos by other people:
2019-05-04 15:07:58 +04:00
- [accelerometer ](https://github.com/GitJer/Some-Sipeed-MAIX-GO-k210-stuff/tree/master/src/accelerometer ) - Example of using the MSA300 accelerometer on the MAIX Go board, by GitJer
2019-05-04 16:38:29 +04:00
2019-05-05 07:25:26 +04:00
- [quake1 ](https://github.com/elect-gombe/quake-k210 ) - Quake 1 on K210. Requires [wiring up a PS2 controller ](https://robotzero.one/quake-kendryte-k210-risc-v/ ).
2019-05-04 16:38:29 +04:00
- [doom1 ](https://github.com/elect-gombe/k210-doom ) - Doom 1 on K210