Author Archives: vonger

VoCore2: Connect to SPI Screen 3

Arrrr!!!! Last day after updated Eagle, I find it is now need to pay monthly…I know this six months delayed. 😅 Stupid autodesk. Thanks God, there is an opensource toolkit named KiCAD. I spend two days to study KiCAD, now EAGLE has moved into trash.

Now continue my adventure.

This time I will show you how to make spi master work.

I am trying to send some data to SPI, and data analyser read like this.

The screen protocol is like this: first bit is command/data bit, 0 means the following bits are command and 1 means the following data is parameter, from the upper picture, my send is data(1) + 0x78 + 0x56 + 0x34, totally it is 25 bits.

Send such SPI package is easy on VoCore2, you will need a directly memory writing tool, mine is mem, link here: http://vonger.cn/misc/vocore2/tools/mem.zip

First. let’s setup its speed. (PS: do not forget download the datasheet) I want to set it to 2Mbps. From datasheet, it is 193.3MHz / (rs_clk_sel + 2) = 2Mbps, we get rs_clk_sel = 94.

Now read the register 0x10000b28, get its current value. We do not need change other bits of 0x10000b28, so we must read it and put same value back to it to make sure it works normal. call “mem 0x10000b28 bit”

root@OpenWrt:/# mem 0x10000b28 bit
31:1 30:1 29:1 28:0 27:0 26:0 25:0 24:0 23:0 22:0 21:0 20:1 19:0 18:0 17:1 16:0
15:1 14:0 13:0 12:0 11:1 10:0 09:0 08:0 07:1 06:0 05:0 04:0 03:0 02:1 01:0 00:0
= 0xE02E8884

rs_clk_sel is 27:16 bits, change the 8bits from 000000010010 to 000000101110 (94 in decimal), so we should set it to 0xe02e8884, call “mem 0x10000b28 0xe02e8884” write back the register.

Rest register is similar, set 0x10000b2c(for short, I will write 0x2c) command length (cmd_bit_cnt) to 1bit, mosi bit (mosi_bit_cnt) to 24bits. 0x04 set to 1, 0x08 set to 0x12345678 (we set data length to 24bits, so spi will only send 0x345678 in 0x78, 0x56, 0x34 order).

Example: set 0x08 to 0x12345678, call “mem 0x10000b08 0x12345678”

Now, the data registers are all ready, we need to tell SPI master pump the data to physics wires. Three steps:

1. enable chip select for spi 1. (0x38 register set to 0x02)
2. start transfer. (0x00 register spi_master_start bit:8)
3. wait data transfer done. (0x00 register spi_master_busy bit:16)
4. disable chip select spi 1. (0x38 register set back to 0)

After this, you will find the same wave as my upper picture.
Looks like everything works smoothly, I should send the commands as ILI9488 datasheet described then everything should work.

But…shit always happening. I find a weird bug on ILI9488 screen 😅  have to stop there a long time and try to detours that weird bug. I will explain on my next blog.😘

VoCore2: wifi driver mt76 vs mtwifi

Use iperf3 test same VoCore2, enable one antenna.

official driver from mediatek:

[ 4] 0.00-1.00 sec 5.46 MBytes 45.8 Mbits/sec
[ 4] 1.00-2.00 sec 5.71 MBytes 47.8 Mbits/sec
[ 4] 2.00-3.00 sec 5.51 MBytes 46.2 Mbits/sec
[ 4] 3.00-4.00 sec 5.24 MBytes 44.0 Mbits/sec
[ 4] 4.00-5.00 sec 5.60 MBytes 47.0 Mbits/sec
[ 4] 5.00-6.00 sec 5.61 MBytes 47.0 Mbits/sec
[ 4] 6.00-7.00 sec 5.64 MBytes 47.3 Mbits/sec
[ 4] 7.00-8.00 sec 5.34 MBytes 44.8 Mbits/sec
[ 4] 8.00-9.00 sec 5.39 MBytes 45.2 Mbits/sec
[ 4] 9.00-10.00 sec 5.34 MBytes 44.8 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 54.8 MBytes 46.0 Mbits/sec sender
[ 4] 0.00-10.00 sec 54.8 MBytes 45.9 Mbits/sec receiver


mt76 driver from LEDE/openwrt(https://github.com/openwrt/mt76):

[ 4] 0.00-1.00 sec 2.29 MBytes 19.2 Mbits/sec
[ 4] 1.00-2.00 sec 2.28 MBytes 19.1 Mbits/sec
[ 4] 2.00-3.00 sec 3.57 MBytes 29.8 Mbits/sec
[ 4] 3.00-4.00 sec 2.98 MBytes 25.1 Mbits/sec
[ 4] 4.00-5.00 sec 4.98 MBytes 41.8 Mbits/sec
[ 4] 5.00-6.00 sec 2.68 MBytes 22.5 Mbits/sec
[ 4] 6.00-7.00 sec 4.21 MBytes 35.4 Mbits/sec
[ 4] 7.00-8.00 sec 3.79 MBytes 31.8 Mbits/sec
[ 4] 8.00-9.00 sec 4.55 MBytes 38.1 Mbits/sec
[ 4] 9.00-10.00 sec 2.79 MBytes 23.5 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 34.1 MBytes 28.6 Mbits/sec sender
[ 4] 0.00-10.00 sec 33.4 MBytes 28.1 Mbits/sec receiver

mt76 driver is not very stable, and speed is only 60% of official driver. 🙂 So there is something I can help to improve.

VoCore2: Connect to SPI Screen 2

I am lucky, the screen backlight is not damaged by my mistake. 😂

1. connect the super tiny driver board to the screen.

 

2. power it up with 3.3V.

The LCD backlight power consume is 5V 100mA, 0.5w, pretty much. I think that’s why the media always says the screen is one of the most power-hungry components in the phone. 😅

Next part, let’s hack SPI and check if we can display anything to it.

PS: many people(include me) find white VoCore2 is hard to clean and go ugly after solder wires, so if no special request, we will ship green pcb version at vocore.io/store(also we still product white pcb version).

VoCore2: Its time to LEDE

Thanks to all LEDE contributors, I just find current LEDE is very fast and stable, I think it is the time to merge all drivers to LEDE 🙂

New LEDE firmware is here: https://downloads.lede-project.org/snapshots/targets/ramips/mt7628/lede-ramips-mt7628-vocore2-squashfs-sysupgrade.bin

Note: make sure you have a USB2TTL, its wifi is default off, as I know that is for secure reason?

Same as usual, I will also share my advanture on this blog.

VoCore2: Fix microSD randomly umount issue

The day before yesterday I released a firmware fixed the microSD randomly umount issue. Now let me explain how it works. (Lastest Firmware: Link)

People report this issue: they find the following log in console when they trying to using microSD.

[ 112.750000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.750000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.760000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.770000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.780000] mmc0: card aaaa removed
[ 112.800000] EXT4-fs error (device mmcblk0p1): ext4_wait_block_bitmap:494: comm kworker/u2:3: Cannot read block bitmap - block_group = 0, block_bitmap = 475
[ 112.820000] EXT4-fs warning (device mmcblk0p1): ext4_end_bio:317: I/O error -5 writing to inode 12 (offset 0 size 4194304 starting block 34175)
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33792
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33793
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33794
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33795
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33796

microSD is umount randomly and microSD card can not use at all.

After some research, I find it is caused by microSD driver. VoCore2 do not have CD(card detect pin), but driver use that pin for card detect, even we already set “cd-poll” and “broken-cd” in VOCORE2.dts, but looks like the mmc driver did not code such flag.

I have to make a patch to fix it.


--- a/drivers/mmc/host/mtk-mmc/sd.c
+++ b/drivers/mmc/host/mtk-mmc/sd.c
@@ -580,6 +580,7 @@
inserted = (status & MSDC_PS_CDSTS) ? 0 : 1;
else
inserted = (status & MSDC_PS_CDSTS) ? 1 : 0;
+ inserted = 1;
}

#if 0
@@ -2328,6 +2329,7 @@
present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1;
else
present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0;
+ present = 1;
host->card_inserted = present;
#endif
spin_unlock_irqrestore(&host->lock, flags);

This upper code force the driver always “believe” the microSD is inserted, so the float CD pin will not randomly unmount microSD card, and let cd-polling do the real card-detect work. 🙂

VoCore2: Firmware Update

This update fixed:

  1. microSD can not auto mount: VoCore2 Ultimate.
  2. microSD driver keep popup noise log to serial console: all version
  3. default IP set to 192.168.61.1
  4. remove several unused package.
  5. fix microSD auto umount randomly bug.

Download at:

VoCore2 Ultimate: vocore2.io/v2u.html (Download/Firmware)
VoCore2: vocore2.io/v2.html (Download/Firmware/128MB)
VoCore2 Lite: vocore2.io/v2.html (Download/Firmware/64MB, for Lite)

VoCore2: Connect to SPI Screen 2

Emm, actually I have made the board at Tuesday, but I get wrong part…😂

My stupid mistake: I plan to use MP3202DJ to powerup the WLED, then I find SY7200AABC have better parameters and price is lower, but forget check its output voltage is 30V and feedback voltage is also double, which is exceed my output cap max allowed voltage…I get a super sudden current when I boot it up, just hope my LCD backlight is still working after the accident.😖

Please lend me a corner and let me cry for a while …

😂😂😂😂😂

VoCore2: Connect to SPI Screen

Last week I find a SPI screen(480×320+262K Color) in the dust, guess it’s time to make it work 🙂

First of all, read read and read.

Actually I can not find much useful information from the lcd datasheet. The two tables should be enough.

LCD have three parts: a driver chip, which is ILI9488; a TFT display, mine is 480×320; backlight, normally is several white LEDs, mine LCD has six of them.

LED- & LED+ the two pins are used to drive white LEDs, drive one LED voltage is 2.5V~3V, six of them in serial will take 15~18V, we will need a boost dcdc chip to reach that voltage, convert 3.3V input to 18V, for simple, just copy and paste the typical sch of the dcdc to my sch).
VCI(2.8V) is the input power for LCD, max allowed voltage is 3.3V, but better to use a small resistor to lower the input voltage to avoid power peak damage the drive chip.
NCS/SDA/SCL is the standard 3-wires SPI interface, we should rename them to SPI CS, SPI DAT, SPI CLK. SPI DAT is for data input and output.

Here is a tricky part, VoCore2 is using 4-wires SPI, which requires four pins: SPI CS, SPI MOSI, SPI MISO, SPI CLK. We must combine SPI MOSI, SPI MISO to SPI DAT, but MISO & MOSI will crosstalk to each other. To lower the crosstalk, we can use a resistor between them.

now I get the final sch:

LCD screen power consume is around 400mW ==> 18V(20mA), and VoCore2 3.3V power output is 200mA~300mA(3.3V 600mW), should be enough.

PCB Layout, two layers, super small, only 0.75×1.34cm, put at top left of vocore2 border 🙂

PS: now the PCB is making in factory, I will get them next week.

You see? Develop hardware is not that hard. 🙂

Tutorial: Use LuCI to make VoCore2 connect to the computer/router via Ethernet

Let’s introduce an easy way to setup VoCore2 with ethernet connection today.

I will use LuCI interface who is very good at this.

Hardware part, let’s use VoCore2 Ultimate as an example —- Ultimate version have an ethernet port which is exported Port 0 on VoCore2.

 

First settings, connect VoCore2 to a router(this router connected to Internet):

Open LuCI, select Network -> Switch -> Select the settings as following picture, then “Save & Apply”

In this mode, normally we use VoCore2 as a wireless AP hotspot, internet from your router through ethernet to VoCore2, and your computer could directly connect to VoCore2 AP hotspot to connect to internet. VoCore2 will enhance your wired network to wireless, just like other wireless router. Once the ethernet connection is working, you can connect to VoCore2 by its IP address, and if you enable samba service on VoCore2, all your computerin the same router will able to access to the files on VoCore2 shared folder.

A nice example is the VoCore2 PoE version, all we need to do is connect it to a PoE router, then near around your VoCore, fast and stable hotspot appears. For online game player, a well signal hotspot means stable internet and win 🙂

Also you can directly connect to your Internet Provider, VoCore2 has PPPoE protocol.

Details please check OpenWRT tutorial(https://wiki.openwrt.org/doc/uci/network, https://wiki.openwrt.org/doc/uci/network/switch).

 

Second settings, connect VoCore2 to a computer directly.

Open LuCI, select Network -> Switch -> Select the settings as following picture, then “Save & Apply”

In this mode, normally we use it to debug VoCore2 when VoCore2 wifi is disabled. Connected computer will get a IP from VoCore2, such as 192.168.61.159.

Some people use this setting as “wireless network to wired network converter”. That needs to use VoCore2 in STA mode(VoCore2 connect to other wireless hotspot then get internet access from it. Please check my youtube video about how to setup VoCore2 in to STA mode), then connect computer to VoCore2 ethernet port by cable.

PS: I do not know why they do this 🙂 Maybe their computers do not have a wireless adaptor on mainboard but have a ethernet port.

Normally I use this mode to debug VoCore2, ethernet is fast and stable, allow me use gdb/gdbserver debug app in real time. When you debug/study wifi driver, ethernet is a good choice too, forget the slow serial console 🙂

VoCore2: Hack the Wifi

Now, open the mystery wifi driver package, we will find two folders, one is build, another is src.

build folder contains two files, one is Kconfig and another is Makefile. The two are standard Linux kernel compile makefile, Kconfig normally used to embed itself to menuconfig and Makefile is used to tell linux compiler which files are necessary to compile the final model(mt7628.ko). More details about Kconfig and Makefile, you can check linux kernel documentation or buy a linux kernel beginner book 🙂

Let’s open Kconfig check what it support:

AP_SUPPORT: emm, I think it is the base function support for wifi AP.
WDS_SUPPORT: WDS, I do not need this, not making a router.
MBSS_SUPPORT: Its full name is MBSSID, ignore, just use default setting. 🙂 I guess this is something related to SSID.
APCLI_SUPPORT: AP + CLIENT mode, absolutely need this.
MAC_REPEATER_SUPPORT,CON_WPS_SUPPORT: …emm, not using yet, use default.
LLTD_SUPPORT: it says “Link Layer Topology Discovery Protocol”, link here: https://en.wikipedia.org/wiki/Link_Layer_Topology_Discovery
AIRPLAY_SUPPORT: not use at all.