Lichee Pi Zero: Notes

What is this?

Just a bunch of notes for doing things with the lichee pi. I had this file going for a few weeks and decided it would be useful for people to know.

In case of errors or contributions, shoot me an email at any email address at sudoforlunch.org, preferably lpi-contrib@sudoforlunch.org. My spammer is a bit paranoid so if I don't respond send another one from gmail or something.

Development setup:

Get buildroot going, figure out how to make buildroot give you arm-buildroot-linux-musleabihf-gcc. Just use this compiler for the kernel as well, it works just fine.

The stock kernel is decent but no SPI support.

Wifi works via SDIO, which is why it fits in that slot. When you do wifi in the SD slot, the mmc interface for the pins on the gpio still exist. Look at the dtbs for more examples.

DTBS:

They all start with sun8i-v3s. Look at those files.

Also, for serious work, solder your headers upside down and buy one of these things, and, um, don't buy the thing on that link, that seems a bit pricy for it. Check aliexpress and dx.com, had good luck with those. You'll want to do the headers upside down because they will interfear with the tf module. That way you don't have to screw around with that tiny sd card.

The great zip file from heaven descendeth upon earth, zero_imager.zip.

I don't remember where this came from, but here is the great collection of stuff you need for the stock kernel, including the good boot.scr file for booting the -dock dtb, as well as a kernel.

zero_imager.zip

I think it has a bad wifi module, here's one you can pretty much just insmod:

r8723bs.ko

I think that will be mainline soon-ish

Booting

To boot, flash one of the dd images, and expand rootfs. Put your own crap in the fat32 boot filesystem, I think a good init is enough. Here's some dd images: kancloud and here's a good image I used which has been mirrored by me brmin_dd.tar.bz2.

Things to note:

Compiling the kernel

I assume you have the buildroot cross compiler in your PATH:

git clone https://github.com/<find_someones>/linux
cd linux
make ARCH=arm licheepi_zero_aditya_defconfig
make ARCH=arm menuconfig # mess around, I know you are here from gentoo
make ARCH=arm CROSS_COMPILE=arm-buildroot-linux-musleabihf- -j8 # This will make your kernel, I think I forgot to enable spidev, do check this.
make ARCH=arm CROSS_COMPILE=arm-buildroot-linux-musleabihf- -j8 INSTALL_MOD_PATH=out modules
make ARCH=arm CROSS_COMPILE=arm-buildroot-linux-musleabihf- -j8 INSTALL_MOD_PATH=out modules_install

Thats about all there is to it.

Audio

Never messed around, but http://bbs.ilichee.cc/t/how-to-test-the-audio-interface/159/4

U-boot

Just.. don't. Okay fine here. Just use the default.

I/O

Serial

ttyS0, S1 and S2 are directly broken out on the board

ttyGS0 is on the USB interface

Probably obvious, but everything is/should be 115200,8n1

SPI is enabled in my kernel, so you can find it at /dev/spidev32766.0, and I think the speed is hardcoded to something high. Usual linux spidev stuff. See note on kernel compilation.

I2C is working fine, /dev/i2c-0 works out of the box.

GPIO

(Thanks to jlsilicon on the forum)

There is a filesystem under /sys/class/gpio, I am going to be working with this as my current directory.

$ echo <PIN> > export
$ echo "out" > gpio<PIN>/direction # For output, or use "in" for input
\# echo 1 or 0 into the gpio<PIN>/value file for output, or read that file for input. 

Some lists for you to use:

SCD1CLK PG0 -G192 - Blue LED
SCD1CMD PG1 -G193 - Green LED
SCD1_D0 PG2 -G194 - Red LED
D1 PG3 -G195
D2 PG4 -G196
D3 PG5 -G197

SCD0_D1 -G160
SCD0_D0 -G161
SCD0CLK -(G162) -DoNotUse
SCD0CMD -(G163) -DoNotUse
SCD0_D3 -G164
SCD0_D2 -G165

U1TX -G149
U1RX -G150

: LIGHT RGB LED = BLUE :
echo 192 > /sys/class/gpio/export
echo “out” > /sys/class/gpio/gpio192/direction
echo 0 > /sys/class/gpio/gpio192/value


J3 Bus :

LCD_D23 PE24 p1 gp152
LCD_D22 PE23 p2 gp151
LCD_D21 PE19 p3 gp147
LCD_D20 PE18 p4 gp146
LCD_D19 PE17 p5 gp145
LCD_D18 PE16 p6 gp144
LCD_D7 PE9 p7 gp137
LCD_D6 PE8 p8 gp136
LCD_D5 PE7 p9 gp135
LCD_D4 PE6 p10 gp134
LCD_D3 PE5 p11 gp133
LCD_D2 PE4 p12 gp132
LCD_D15 PE15 p13 gp143
LCD_D14 PE14 p14 gp142
LCD_D13 PE13 p15 gp141
LCD_D12 PE12 p16 gp140
LCD_D11 PE11 p17 gp139
LCD_D10 PE10 p18 gp138
LCD_VSYNC PE3 p19 gp131
LCD_HSYNC PE2 p20 gp130

GPIOs Table:

GPIO 128 IO.E00
GPIO 129 IO.E01
GPIO 130 PE2 HSYNC
GPIO 131 PE3 VSYNC
GPIO 132 PE4
GPIO 133 PE5
GPIO 134 PE6
GPIO 135 PE7
GPIO 136 PE8
GPIO 137 PE9
GPIO 138 PE10
GPIO 139 PE11
GPIO 140 PE12
GPIO 141 PE13
GPIO 142 PE14
GPIO 143 PE15
GPIO 144 PE16
GPIO 145 PE17
GPIO 146 PE18
GPIO 147 PE19
GPIO 148 IO.E20
GPIO 149 U1TX PE21
GPIO 150 U1RX PE22
GPIO 151 PE23
GPIO 152 PE24
: PB :
GPIO 32 – U2TX PB0
GPIO 33 – U2RX PB1

GPIO 34 – IO.B2 RTS
GPIO 35 – IO.B3 CTS

GPIO 36 – PWM0 PB4 -DoNotUse
GPIO 37 – PWM1 PB5 -Use ?
GPIO 38 – TWI0_SCK PB6
GPIO 39 – TWI0_SDA PB7 -Use ?

: PC :
GPIO 64 – SPI_MISO PC0
GPIO 65 – SPI_SCK PC1
GPIO 66 – SPI_CS PC2 ?
GPIO 67 – SPI_MOSI PC3
Outer Side Pins :
(Side Corner opposite RGB-LED)

IO.E01 - GPIO 129
IO.E00 - GPIO 128
IO.E20 - GPIO 148
IO.B02 RTS - GPIO 34
IO.B03 CTS - GPIO 35

Note: IO.E01 / L## - refers to the Pin Name from the LicheePi chip Pinout Diagram ,
GPIO # refers to /sys/class/gpio/gpio# command used in Linux

    Total usable Pins : seems to be about (48) usable GPIO pins (51pins - (~3) reserved)
    Caution : some of the Pins (marked above) may interfere with the Board working correctly (Clocks / SdCard SPI)

Ports PF and PG as GPIO # Map :

: PF :
160 io SCD0_D1 PF0
161 io SCD0_D0 PF1
162 bad (SCD0_CLK PF2)
163 bad (SCD0_CMD PF3)
164 io SCD0_D3 PF4
165 io SCD0_D2 PF5

: PG :
192 io SCD1_CLK PG0 BLUE LED
193 io SCD1_CMD PG1 GREEN LED
194 io SCD1_D0 PG2 RED LED
195 io SCD1_D1
196 io SCD1_D2
197 io SCD1_D3

: PG :
SCD1CLK PG0 - G192 - Blue LED
SCD1CMD PG1 - G193 - Green LED
SCD1_D0 PG2 - G194 - Red LED
D1 PG3 - G195
D2 PG4 - G196
D3 PG5 - G197

Linux 4.13:

It builds fine, the wifi driver is now staging, grab it and you are good. My branch is:

It has the required dtsi edits and the dts edits in the -dock dts file. You have 3 serial ports, and spi and i2c

licheepi_zero_aditya_defconfig has it all