Quick jump:  What's new

 
Go to:
 
Weblog: Recent Changes   
in Dobrica Pavlinušić's random unstructured stuff
Teckin SP22

Photos: https://photos.app.goo.gl/JBW4wv51Eb6RX1ej8

Board markings

PLD-PZ005-V1.9.
12/13/2018

wifi module

LA_WF3_08.png

TYWE2S

pins on flat side (bottom)

3v3
gnd
rx
tx
12
14

pins on side with components

rst
ad
13
04
05

sonoff tasmota

{"NAME":"Teckin","GPIO":0,17,0,53,134,132,0,0,131,56,21,0,0,"FLAG":0,"BASE":52}
permalink
lirc

Hints about using recent lirc



ir-ctl

install

# apt install v4l-utils

root@nuc2:~# ir-ctl --features
Receive features /dev/lirc0:
 - Device can receive raw IR
 - Set receive carrier
 - Can set recording timeout min:100000 microseconds max:1000000 microseconds
Send features /dev/lirc0:
 - Device can send raw IR
 - Set carrier
 - Set duty cycle

sniff

root@nuc2:~# ir-ctl -r -m -v

gpio-ir-tx

send IR signals using GPIO on cubieboard

device tree

https://github.com/dpavlin/linux-gpio-pinout/blob/master/device-tree/gpio-ir-tx.dts

/*
 * add gpio-ir-tx to enable ir send on sunxi
 * for RM Mini 3 IR board connected to pins
 */

/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

	/* Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt */
	fragment@0 {
		target-path = "/";

		__overlay__ {
			irled@0 {
				compatible = "gpio-ir-tx";
				gpios = <&pio 1 10 0>; /* PB10 GPIO_ACTIVE_HIGH */
			};

		};
	};
};

root@cubieboard:~# modinfo gpio-ir-tx
filename:       /lib/modules/4.19.44-sunxi/kernel/drivers/media/rc/gpio-ir-tx.ko
license:        GPL
author:         Sean Young <sean@mess.org>
description:    GPIO IR Bit Banging Transmitter
alias:          of:N*T*Cgpio-ir-txC*
alias:          of:N*T*Cgpio-ir-tx
depends:        
intree:         Y
name:           gpio_ir_tx
vermagic:       4.19.44-sunxi SMP mod_unload ARMv7 thumb2 p2v8 

root@cubieboard:/home/dpavlin/linux-gpio-pinout# armbian-add-overlay device-tree/gpio-ir-tx.dts
Compiling the overlay
Copying the compiled overlay file to /boot/overlay-user/
Reboot is required to apply the changes

root@cubieboard:/home/dpavlin/linux-gpio-pinout# ./overlay-load.sh /boot/overlay-user/gpio-ir-tx.dtbo
+ dtb=/boot/overlay-user/gpio-ir-tx.dtbo
+ test -f /boot/overlay-user/gpio-ir-tx.dtbo
+ + awkmount { print $3 }
 -t configfs
+ config=/sys/kernel/config
+ basename /boot/overlay-user/gpio-ir-tx.dtbo
+ name=gpio-ir-tx.dtbo
+ dir=/sys/kernel/config/device-tree/overlays/gpio-ir-tx.dtbo
+ test -d /sys/kernel/config/device-tree/overlays/gpio-ir-tx.dtbo
+ mkdir /sys/kernel/config/device-tree/overlays/gpio-ir-tx.dtbo
+ cat /boot/overlay-user/gpio-ir-tx.dtbo
+ cat /sys/kernel/config/device-tree/overlays/gpio-ir-tx.dtbo/status
applied
root@cubieboard:/home/dpavlin/linux-gpio-pinout# [Sun Jun  2 19:51:10 2019] rc rc1: GPIO IR Bit Banging Transmitter as /devices/platform/irled@0/rc/rc1
[Sun Jun  2 19:51:10 2019] rc rc1: lirc_dev: driver gpio-ir-tx registered at minor = 1, no receiver, raw IR transmitter
[Sun Jun  2 19:51:10 2019] rc rc1: GPIO IR Bit Banging Transmitter as /devices/platform/irled@0/rc/rc1
[Sun Jun  2 19:51:10 2019] rc rc1: lirc_dev: driver gpio-ir-tx registered at minor = 1, no receiver, raw IR transmitter

root@cubieboard:~# apt-get install v4l-utils # to get ir-ctl

root@cubieboard:~# ir-ctl --device /dev/lirc1 --features
Receive features /dev/lirc1:
 - Device cannot receive
Send features /dev/lirc1:
 - Device can send raw IR
 - Set carrier
 - Set duty cycle


diff --git a/lirc/lirc_options.conf b/lirc/lirc_options.conf
index d6ddfcf..d5a6648 100644
--- a/lirc/lirc_options.conf
+++ b/lirc/lirc_options.conf
@@ -8,8 +8,8 @@
 
 [lircd]
 nodaemon        = False
-driver          = devinput
-device          = auto
+driver          = default
+device          = /dev/lirc0
 output          = /var/run/lirc/lircd
 pidfile         = /var/run/lirc/lircd.pid
 plugindir       = /usr/lib/arm-linux-gnueabihf/lirc/plugins

root@cubieboard:/etc/lirc# ls -al /etc/lirc/lircd.conf.d/
total 52
drwxr-xr-x 2 root root  4096 Jun  2 21:04 .
drwxr-xr-x 3 root root  4096 Jun  2 21:57 ..
-rw-r--r-- 1 root root 33704 Apr  6  2017 devinput.lircd.conf.disabled
-rw-r--r-- 1 root root  3383 Jun  2 18:52 lg.conf
-rw-r--r-- 1 root root   615 Apr  6  2017 README.conf.d

root@cubieboard:/etc/lirc# cat /etc/lirc/lircd.conf.d/lg.conf 
#
# this config file was automatically generated
# using lirc-0.8.2(iguanaIR) on Thu Jul 15 09:15:21 2010
#
# contributed by Stale Nestas
#
# brand:  LG
# model no. of remote control:
# devices being controlled by this remote: LG42H3000
#

begin remote

  name  LG_42H3000
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9008  4442
  one           533  1652
  zero          533   533
  ptrail        535
  repeat       9001  2204
  pre_data_bits   16
  pre_data       0x20DF
  gap          107753
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x10EF                    #  Was: power
          input                    0xD02F
          energy                   0xA956
          tv/rad                   0x0FF0
          avmode                   0x0CF3
          KEY_1                    0x8877                    #  Was: 1
          KEY_2                    0x48B7                    #  Was: 2
          KEY_3                    0xC837                    #  Was: 3
          KEY_4                    0x28D7                    #  Was: 4
          KEY_5                    0xA857                    #  Was: 5
          KEY_6                    0x6897                    #  Was: 6
          KEY_7                    0xE817                    #  Was: 7
          KEY_8                    0x18E7                    #  Was: 8
          KEY_9                    0x9867                    #  Was: 9
          KEY_0                    0x08F7                    #  Was: 0
          KEY_LIST                 0xCA35                    #  Was: list
          qview                    0x58A7
          KEY_VOLUMEUP             0x40BF                    #  Was: vol+
          KEY_VOLUMEDOWN           0xC03F                    #  Was: vol-
          KEY_MUTE                 0x906F                    #  Was: mute
          KEY_CHANNELUP            0x00FF                    #  Was: p+
          KEY_CHANNELDOWN          0x807F                    #  Was: p-
          KEY_UP                   0x02FD                    #  Was: up
          KEY_DOWN                 0x827D                    #  Was: down
          KEY_LEFT                 0xE01F                    #  Was: left
          KEY_RIGHT                0x609F                    #  Was: right
          KEY_OK                   0x22DD                    #  Was: ok
          KEY_MENU                 0xC23D                    #  Was: menu
          KEY_EXIT                 0x14EB                    #  Was: return/exit
          KEY_RED                  0x4EB1                    #  Was: red
          KEY_GREEN                0x8E71                    #  Was: green
          KEY_YELLOW               0xC639                    #  Was: yellow
          KEY_BLUE                 0x8679                    #  Was: blue
          KEY_TEXT                 0x04FB                    #  Was: text
          topt                     0x847B
          KEY_SUBTITLE             0x9C63                    #  Was: subtitle
          simplink                 0x7E81
          qmenu                    0xA25D
          KEY_INFO                 0x55AA                    #  Was: info
#          KEY_INFO                 0xD52A                    #  Was: guide
          KEY_FAVORITES            0x7887                    #  Was: fav
      end codes

end remote





RaspberryPi

https://www.raspberrypi.org/forums/viewtopic.php?t=235256

sudo apt install dh-exec doxygen expect libasound2-dev libftdi1-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libusb-dev man2html-base portaudio19-dev socat xsltproc python3-yaml dh-python libx11-dev python3-dev python3-setuptools
mkdir build
cd build
apt source lirc
wget https://raw.githubusercontent.com/neuralassembly/raspi/master/lirc-gpio-ir-0.10.patch
patch -p0 -i lirc-gpio-ir-0.10.patch
cd lirc-0.10.1
debuild -uc -us -b
cd ..
sudo apt install ./liblirc0_0.10.1-5.2_armhf.deb ./liblircclient0_0.10.1-5.2_armhf.deb ./lirc_0.10.1-5.2_armhf.deb 

so, let's rebuild lircd

pi@rpi2 ~ $ sudo apt-get build-dep lirc
pi@rpi2 ~ $ sudo bash
root@rpi2:/home/pi# mkdir build-lirc
root@rpi2:/home/pi# cd build-lirc/

root@rpi2:/home/pi/build-lirc# apt source lirc

root@rpi2:/home/pi/build-lirc# wget https://raw.githubusercontent.com/neuralassembly/raspi/master/lirc-gpio-ir-0.10.patch

root@rpi2:/home/pi/build-lirc# patch -p0 -i lirc-gpio-ir-0.10.patch

root@rpi2:/home/pi/build-lirc# cd lirc-0.10.1/

root@rpi2:/home/pi/build-lirc/lirc-0.10.1# apt install devscripts # debuild

root@rpi2:/home/pi/build-lirc/lirc-0.10.1# debuild -uc -us -b


permalink
Lenovo Thinkpad Tablet

Product Numbers: 1838, 1839

Tegra 2 tablet, possible kernel name (from schematics, not used as-is): PHJ00

Board markings: LA-746

PHJ00LA-7561P
Rev:1.0
2011-06-03

schematics: compal_la-7461p_r0.3_schematics.pdf

Contents: [Dobrica Pavlinušić's random unstructured stuff]


links

Review:

dock connector

https://web.archive.org/web/20150108184014/http://rootzwiki.com:80/topic/8523-reverse-engineering-the-dock-charger/

Posted 31 October 2011 - 03:09 AM #1
I got my desktop charger today and unpacked it only to rip it aparts to check whats inside.
By first view theese are the highlights:

The dock connector is 40 pins
Dock connector is on a separate small pcb with a 40 pin board to board connector to a larger board.
On this small pcb is a 12 pin MLF package marked:
AAU
NAD

Probably has a ground pad underneath.

The main pcb has a few more circuits and connectors on it.
There is a micro usb, a full size master usb, audio out and microphone jacks. A bit more exiting there is room for a HDMI connector as well there with unpopulated spaces for line filters and a hdmi circuit. By first look it seems to be a displayport or MHL to HDMI bridge chip of some kind. I is TQFP-48 package.
edit:
It seems to be a PI3VDP411LS from pericom
http://www.pericom.c...PI3VDP411LS.pdf

It is a displayport levelshifter / bridge to HDMI. It is the only 48 pin package I have found to match the input with the differential pairs.

The power supply is 20 VDC 65 Watts. It does not seem like the center connector is connected. The connector is the standard "IBM" charger, outer case ground, inner case + 20 vdc, center pin power diag.

There is a fet transistor between the dock connector and the psu marked FA1K18 and it is controlled by some regulator marked 920A4 in a SOT-223 package. The 20 VDC goes in on pin 2 and the tab on it.

the HDMI chip has differential pair inputs on pin 47,48 - 44,45 - 41,41 - 38,39

I will do my best reversing the whole schematic for this unit and split it into parts so we can make other chargers and hopefully add HDMI to the dock.

Pinout Docking Connector Thinkpad Tablet

1 charge 2 gnd
3 charge 4 hdmi pin 44 In D3-
5 Charger control (to pq2) 6 hdmi pin 45 In D3+
7 hdmi VDD 3.3V 8 gnd
9 gnd 10 hdmi pin 47 In D4-
11 USB Micro D- 12 hdmi pin 48 In D4 +
13 USB micro D+ 14 gnd
15 USB Master D- 16 nc
17 USB MAster D+ 18 nc
19 gnd 20 hdmi pin 29 SDA
21 gnd 22 hdmi pin 28 SCL
23 hdmi pin 41 IN D2- 24 hdmi pin 7 HPD_Source
25 hdmi pin 42 In D2+ 26 gnd
27 gnd 28 audio out L
29 hdmi pin 38 IN D1- 30 audio out R
31 hdmi pin 39 IN D1+ 32 headset inserted switch
33 gnd 34 mic inserted switch feed
35 USB micro + 36 mic inserted switch
37 gnd 38 mic tip
39 + 5V to usb master 40 mic ring

Pinout AAU chipAAU chip is audio amp.
audio out
pin 10 ring
pin 11 tip
pin 2, 7 gnd

Charger stuff :
The supplied DC apater is 20Volt 3.25Amps
In the dock there is a voltage regulator PV1. It is a 3.3 V LDO Tab has 20 volts in and pin 3 gives 3.30 Volts out.
There is also a FET in SSO8 (?) package. It is controlled by 2 transistors and works only as a switch.
On the base of PQ2 (pin 1, I guess it is the base) there is a float of 3.30 volts when there is nothing in the dock. The FET is OPEN and no voltage to the charger pins.
When grounding PQ2 pin1 (dock pin 5) the FET CLOSES and the charger outputs 20,5volts which basically is the same as dc power into the dock.

Now I am just waiting for the TPT to get fully charged so I can measure if there is any difference when fully charged.

Note:
By charging at 20 volts instead of 5 volts I understand why the charger only uses 2 pins into the TPT.
At 20 volts you can transfer 4 times the energy instead of just charging at 5 volts from USB powers. There is no need for step ups to charge the LI-Po battery as it would need more than 5 volts.

This is the schematics of the charger part:

www.r-888.com/tpt/schema.pdf

I am not sure of the 2 transitors if they are pnp or npn yet but the rest is how it is.
The original mosfet is a P-channel AON7403.
The regulator is just any 3,3 volt LDO.

The TPT charger control pin 5 gets a 3,3 volt float via the resistor to the left in the schematic. When it is connected the TPT grounds the pin and the FET lets current through.

Edited by ZebCrs, 05 November 2011 - 12:56 PM.

adb

[Tue Oct  9 14:12:34 2018] usb 2-4: new high-speed USB device number 9 using xhci_hcd
[Tue Oct  9 14:12:34 2018] usb 2-4: New USB device found, idVendor=17ef, idProduct=7494, bcdDevice=99.99
[Tue Oct  9 14:12:34 2018] usb 2-4: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[Tue Oct  9 14:12:34 2018] usb 2-4: Product: ThinkPadTablet
[Tue Oct  9 14:12:34 2018] usb 2-4: Manufacturer: LENOVO
[Tue Oct  9 14:12:34 2018] usb 2-4: SerialNumber: MP1YCPF

dpavlin@klin:~$ adb devices
List of devices attached
MP1YCPF device

dpavlin@klin:~$ adb shell
shell@android:/ $ df
Filesystem             Size   Used   Free   Blksize
/dev                   357M    32K   357M   4096
/mnt/asec              357M     0K   357M   4096
/mnt/obb               357M     0K   357M   4096
/sqlite_stmt_journals     4M     0K     4M   4096
/system                755M   310M   445M   4096
/data                   56G     1G    54G   4096
/cache                 885M    81M   804M   4096
/mnt/pia               492M   233M   258M   4096
/mnt/persdata           19M     8M    11M   4096
/storage/sdcard0        56G     1G    54G   4096


shell@android:/ # uname -a
Linux localhost 2.6.39.4-g40c7636-dirty #1 SMP PREEMPT Thu Feb 7 20:07:37 CET 2013 armv7l GNU/Linux


1|shell@android:/ # cat /proc/cpuinfo                                          
Processor       : ARMv7 Processor rev 0 (v7l)
processor       : 0
BogoMIPS        : 996.14

processor       : 1
BogoMIPS        : 996.14

Features        : swp half thumb fastmult vfp edsp vfpv3 vfpv3d16 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x1
CPU part        : 0xc09
CPU revision    : 0

Hardware        : ventana
Revision        : 0000
Serial          : 0000000000000000


shell@android:/ # free
             total         used         free       shared      buffers
Mem:        731896       720924        10972            0        18392
-/+ buffers:             702532        29364
Swap:            0            0            0


shell@android:/ # cat /proc/partitions                                         
major minor  #blocks  name

 179        0   62520320 mmcblk0
 179        1       6144 mmcblk0p1
 179        2       8192 mmcblk0p2
 179        3     786432 mmcblk0p3
 179        4     921600 mmcblk0p4
 179        5       2048 mmcblk0p5
 179        6     524288 mmcblk0p6
 179        7      20480 mmcblk0p7
 259        0     143360 mmcblk0p8
 259        1      20480 mmcblk0p9
 259        2   60071936 mmcblk0p10



APX mode

  • turn off tablet
  • press rotation button and hold it
  • press power button for 2 seconds
 [Tue Oct  9 14:30:41 2018] usb 2-4: new high-speed USB device number 16 using xhci_hcd
[Tue Oct  9 14:30:42 2018] usb 2-4: New USB device found, idVendor=0955, idProduct=7820, bcdDevice= 1.04
[Tue Oct  9 14:30:42 2018] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Tue Oct  9 14:30:42 2018] usb 2-4: Product: APX
[Tue Oct  9 14:30:42 2018] usb 2-4: Manufacturer: NVIDIA Corp.



nvflash

https://forum.xda-developers.com/showthread.php?t=1745450

dpavlin@klin:/virtual/android/tegra/linux4tegra/nvflash$ LD_LIBRARY_PATH=. ./nvflash --bl ../prebuilt/fastboot.stock.bin --getpartitiontable /klin/Tegra/tpt1.nvflash.getpartitiontable
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 4
   chip sku: 0x8
   chip uid: 0x0a8051c743dfd457
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: ../prebuilt/fastboot.stock.bin
| 936016/936016 bytes sent
../prebuilt/fastboot.stock.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
failed executing command 19 NvError 0x120000
command failure: get partition table failed 

partition table

dpavlin@nuc:/nuc/Tegra/nvflash$ LD_LIBRARY_PATH=. ./nvflash --bl ../04.EBT.img --getpartitiontable partitiontable.txt --go
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 4
   chip sku: 0x8
   chip uid: 0x043c71c3433f8497
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 2

downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: ../04.EBT.img
/ 6291456/6291456 bytes sent
../04.EBT.img sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
Succesfully updated partition table information to partitiontable.txt



backup

dpavlin@nuc:/nuc/Tegra/nvflash$ grep PartitionId partitiontable.txt  | cut -d= -f2 | tr -d '\r' | xargs -i ./nvflash -r --read {} {}

# even better version which removes biggest partition (15)

dpavlin@klin:/klin/Tegra/nvflash$ grep PartitionId partitiontable.txt  | cut -d= -f2 | tr -d '\r' | grep -v 15 | xargs -i ../nvflash/nvflash -r --read {} {}



BCT - Boot Configuration Table

https://http.download.nvidia.com/tegra-public-appnotes/bct-overview.html

compiler: https://github.com/NVIDIA/cbootimage

dpavlin@klin:/klin/Tegra/tegrarcm$ ./src/tegrarcm readbct --bct tpt.bct

[Wed Oct 10 14:31:05 2018] usb 3-1.1: new high-speed USB device number 23 using ehci-pci
[Wed Oct 10 14:31:05 2018] usb 3-1.1: New USB device found, idVendor=0955, idProduct=7820, bcdDevice= 1.04
[Wed Oct 10 14:31:05 2018] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed Oct 10 14:31:05 2018] usb 3-1.1: Product: APX
[Wed Oct 10 14:31:05 2018] usb 3-1.1: Manufacturer: NVIDIA Corp.

bct file: tpt.bct
device id: 0x7820
uid:  0x0a805185415fc1d7
RCM version: 2.1
downloading miniloader to target at address 0x40008000 (132976 bytes)...
miniloader downloaded successfully
reading BCT from system, writing to tpt.bct...done!



serial

From android:

shell@android:/ # cat /proc/cmdline                                            
tegraid=20.1.4.0.0 mem=1022M@0M android.commchip=2685344 vmalloc=256M androidboot.serialno=0a805185415fc1d7 video=tegrafb no_console_suspend=1 console=none debug_uartport=lsport,-3 usbcore.old_scheme_first=1 lp0_vec=8192@0x1d826000 tegra_fbmem=8197120@0x1d82a000 tegraboot=sdmmc charging=0 isBatteryFail=0 gpt gpt_sector=125040639 


shell@android:/ # lsof | grep tty                                              
rild        103      radio   13       ???                ???       ???        ??? /dev/ttyACM1
brcm_patc   330  bluetooth    3       ???                ???       ???        ??? /dev/ttyHS2
sh         1789      shell   24       ???                ???       ???        ??? /dev/tty
sh         1795       root   24       ???                ???       ???        ??? /dev/tty

shell@android:/ # dmesg | grep tty                                             
<6>[    6.290150] serial8250.0: ttyS0 at MMIO 0x70006300 (irq = 122) is a Tegra
<6>[    6.290475] tegra_uart.1: ttyHS1 at I/O 0x0 (irq = 69) is a unknown
<6>[    6.290727] Registered UART port ttyHS1
<6>[    6.290873] tegra_uart.2: ttyHS2 at I/O 0x0 (irq = 78) is a unknown
<6>[    6.291115] Registered UART port ttyHS2
<6>[    7.056012] cdc_acm 1-1:1.1: ttyACM0: USB ACM device
<6>[    7.067323] cdc_acm 1-1:1.3: ttyACM1: USB ACM device
<6>[    7.137758] cdc_acm 1-1:1.9: ttyACM2: USB ACM device
<4>[   15.154176] ttyACM1: Entering acm_tty_open.



serial port

Schematic has 4 pin debug connector with serial on it.

There are three 4-pin connectors on this side of board, and from pictures other side doesn't seem to have connectors.

Skip JLTE1 and JLTE2 connector (under ribbon to front-facing camera), they are wrong connectors, and pop rf shield off Tegra
compartment and locate JP4:

IMG_20181024_165607-800px.jpg

solder pin 1 and 2 and ground

IMG_20181024_172303-800px.jpg

JP4 pinout from schematics:

  • 1 - UART4_RXD
  • 2 - UART4_TXD
  • 3
  • 4 - GND

Pins 1 and 2 are 1.8V when device is turned on. so far, so good.

u-boot

dpavlin@klin:/klin/Tegra/u-boot-tegra$ export CROSS_COMPILE="arm-none-eabi-" ARCH=arm
dpavlin@klin:/klin/Tegra/u-boot-tegra$ make ventana_defconfig

press left-most button and power (top-right of tablet)

[Sun Oct 21 16:29:05 2018] usb 1-3.4.1: pl2303 converter now attached to ttyUSB3
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: new high-speed USB device number 105 using xhci_hcd
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: New USB device found, idVendor=0955, idProduct=7820, bcdDevice= 1.04
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: Product: APX
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: Manufacturer: NVIDIA Corp.

# backup bct

dpavlin@nuc:/nuc/Tegra/tpt-brokenscreen$ ../tegrarcm/src/tegrarcm --bct broken.bct readbct
bct file: broken.bct
device id: 0x7820
uid:  0x0a805185415fc1d7
RCM version: 2.1
downloading miniloader to target at address 0x40008000 (132976 bytes)...
miniloader downloaded successfully
reading BCT from system, writing to broken.bct...done!

# try u-boot

dpavlin@nuc:/nuc/Tegra/tpt-brokenscreen$ ../tegrarcm/src/tegrarcm --bct broken.bct --bootloader /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin --loadaddr 0x108000

bct file: broken.bct
bootloader file: /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin
load addr 0x108000
entry addr 0x108000
device id: 0x7820
uid:  0x0a805185415fc1d7
RCM version: 2.1
downloading miniloader to target at address 0x40008000 (132976 bytes)...
miniloader downloaded successfully
Chip UID:                0x00000000000000000a805185415fc1d7
Chip ID:                 0x20
Chip ID Major Version:   0x1
Chip ID Minor Version:   0x4
Chip SKU:                0x8 (t20)
Boot ROM Version:        0x1
Boot Device:             0x2 (EMMC)
Operating Mode:          0x3 (developer mode)
Device Config Strap:     0x0
Device Config Fuse:      0x0
SDRAM Config Strap:      0x1
sending file: broken.bct
- 4080/4080 bytes sent
broken.bct sent successfully
sending file: /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin
/ 496836/496836 bytes sent
/mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin sent successfully
dpavlin@nuc:/nuc/Tegra/tpt-brokenscreen$ 
[Sun Oct 21 16:39:58 2018] usb 1-3.4.4: USB disconnect, device number 108

Complete nfsroot with u-boot is documented in u-boot page.

screen

LG LP101WX1 - datasheet - https://datasheetspdf.com/pdf-file/788219/LG/LP101WX1-SLN2/1

and screen seems to work with changes ported from 2.6!

                                display-timings {
                                        timing@0 {
                                                /* XXX tegra_dc_mode ventana_panel_modes */
                                                clock-frequency = <72072000>;
                                                hactive = <1280>;
                                                vactive = <800>;
                                                hback-porch = <72>;
                                                hfront-porch = <48>;
                                                hsync-len = <32>;
                                                vback-porch = <22>;
                                                vfront-porch = <3>;
                                                vsync-len = <7>;
                                                hsync-active = <1>;
                                        };
                                };



flash u-boot to emmc

based on https://github.com/Stuw/ac100-self-installers/blob/master/switch-to-uboot/install_bootloader.sh

root@tegra20:/home/dpavlin# dd if=/dev/mmcblk2boot0 of=mmcblk2boot0 bs=4080 count=1

root@tegra20:/home/dpavlin# echo 0 > /sys/block/mmcblk2boot0/force_ro 
root@tegra20:/home/dpavlin# echo 0 > /sys/block/mmcblk2boot1/force_ro 

root@tegra20:/home/dpavlin# bct_dump mmcblk2boot0 > bct.cfg

root@tegra20:/home/dpavlin# scp dpavlin@klin:/klin/Tegra/u-boot-tegra/u-boot-tegra.bin .

Rest of procedure is based on my changes for phj00: https://github.com/dpavlin/cbootimage-configs/tree/phj00

root@tegra20:/home/dpavlin/cbootimage-configs/tegra20/nvidia/phj00# make
cbootimage -t20 phj00-emmc.img.cfg phj00-emmc.img
Image file phj00-emmc.img has been successfully generated!

root@tegra20:/home/dpavlin/cbootimage-configs/tegra20/nvidia/phj00# dd if=phj00-emmc.img of=/dev/mmcblk2boot0 

modify u-boot boot.cmd to boot from mmc

root@tegra20:/boot# cat boot.cmd

setenv bootargs root=/dev/mmcblk2p1 panic=60
ext2load mmc 0 ${kernel_addr_r} /boot/zImage
ext2load mmc 0 ${fdt_addr_r} /boot/tegra20-ventana.dtb
ext2load mmc 0 ${ramdisk_addr_r} /boot/uInitrd

bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# mkimage -C none -A arm -T script -d boot.cmd boot.scr

Victory: booting from mmc

wifi

dpavlin@tegra20:~$ dmesg | grep brcm
[   13.971076] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4329-sdio for chip BCM4329/3

apt-get install firmware-brcm80211

# it seems to need some non-free parts

root@tegra20:/home/dpavlin# cd /lib/firmware/brcm/
wget https://raw.githubusercontent.com/armbian/firmware/master/brcm/brcmfmac4329-sdio.txt


And to make it work on 5.0 kernel you also need specific symlink for device:

root@tegra20:/lib/firmware# dmesg | grep firmware
[    5.748888] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[   14.614802] brcmfmac mmc0:0001:1: Direct firmware load for brcm/brcmfmac4329-sdio.nvidia,ventana.txt failed with error -2
[  447.338018] brcmfmac mmc0:0001:1: Direct firmware load for brcm/brcmfmac4329-sdio.nvidia,ventana.txt failed with error -2

root@tegra20:/lib/firmware/brcm# ln -sf brcmfmac4329-sdio.txt brcmfmac4329-sdio.nvidia,ventana.txt 

battery and EC

without any config with ventana dts battery isn't charging which is annoying for development because you need to charge tablet often.

according to schematics charger is: ISL9519HRTZ-T_TQFN28_4X4

https://www.intersil.com/content/dam/intersil/documents/isl9/isl9519.pdf (too short, not useful)

There seems to be patch to add isl9519q to kernel back from 2011: https://lkml.org/lkml/2011/8/29/312
which judging from one datasheet that google can find ISL9519C-Intersil.pdf is roughly correct.

However, it's connected to KB930QF-A1_LQFP128_14X14 which seems to be bios controller chip based
on 8051 core with custom firmware and 2.6 driver is https://github.com/dpavlin/linux/blob/thinktabletopensource-2.6.36/drivers/power/EC_battery.c

embedded controller i2c

turn charning on

After connecting usb, issue following command to start charging battery:

i2cset -y 5 0x58 0x5b 0x0001 w

turn watchdog off

root@tegra20:~# cat /home/dpavlin/ec-disable-watchdog.sh 
#!/bin/sh

# i2c_smbus_write_word_data(EC_Bat_device->client,0x46,0

i2cset -y 5 0x58 0x46 0x0000 w

root@tegra20:~# cat /etc/systemd/system/phj00-disable-watchdog.service 
[Unit]
Description=phj00 watchdog disable
After=local-fs.target

[Service]
User=root
Type=oneshot
ExecStart=/home/dpavlin/ec-disable-watchdog.sh

[Install]
WantedBy=multi-user.target
root@tegra20:~# systemctl enable phj00-disable-watchdog.service 
root@tegra20:~# systemctl start phj00-disable-watchdog.service 

shutdown, reboot

root@tegra20:~# cat /lib/systemd/system-shutdown/phj00-shutdown.sh 
#!/bin/sh

echo "DEBUG $0 -- $*"

case "$1" in
        halt|poweroff)
                # shutdown
                i2cset -y 5 0x58 0x52 0x0000 w
                ;;
        reboot)
                # restart
                i2cset -y 5 0x58 0x55 0x0001 w
                ;;
        *)
                echo "WARNING: $1 ignored"
                ;;
esac

kernel 2.6 drivers

custom drivers: https://github.com/dpavlin/linux/tree/thinktabletopensource-2.6.36/drivers/phj00

i2c

mainline 4.19

root@tegra20:~# i2cdetect -l     
i2c-3   i2c             7000d000.i2c                            I2C adapter
i2c-1   i2c             7000c400.i2c                            I2C adapter
i2c-4   i2c             i2c-1-mux (chan_id 0)                   I2C adapter
i2c-2   i2c             7000c500.i2c                            I2C adapter
i2c-0   i2c             7000c000.i2c                            I2C adapter
i2c-5   i2c             i2c-1-mux (chan_id 1)                   I2C adapter

root@tegra20:~# i2cdetect -y -r 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- UU -- 1c -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 1 # very slow
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- 0c -- -- 0f 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 4
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 5
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# grep . /sys/bus/i2c/devices/*/name
/sys/bus/i2c/devices/0-001a/name:wm8903
/sys/bus/i2c/devices/0-0044/name:isl29018
/sys/bus/i2c/devices/3-0034/name:tps6586x
/sys/bus/i2c/devices/3-004c/name:nct1008
/sys/bus/i2c/devices/i2c-0/name:7000c000.i2c
/sys/bus/i2c/devices/i2c-1/name:7000c400.i2c
/sys/bus/i2c/devices/i2c-2/name:7000c500.i2c
/sys/bus/i2c/devices/i2c-3/name:7000d000.i2c
/sys/bus/i2c/devices/i2c-4/name:i2c-1-mux (chan_id 0)
/sys/bus/i2c/devices/i2c-5/name:i2c-1-mux (chan_id 1)



kernel 2.6 (android)

shell@android:/ # grep . /sys/bus/i2c/devices/*/name                           
/sys/bus/i2c/devices/0-001a/name:wm8903
/sys/bus/i2c/devices/0-001c/name:al3000a_ls
/sys/bus/i2c/devices/1-003a/name:nvhdcp1
/sys/bus/i2c/devices/1-0050/name:tegra_edid
/sys/bus/i2c/devices/2-0050/name:phj00_lcd
/sys/bus/i2c/devices/2-0058/name:EC_Battery
/sys/bus/i2c/devices/3-003c/name:mt9p111
/sys/bus/i2c/devices/3-003d/name:mt9d115
/sys/bus/i2c/devices/4-000c/name:akm8975
/sys/bus/i2c/devices/4-000f/name:kxtf9
/sys/bus/i2c/devices/4-0034/name:tps6586x
/sys/bus/i2c/devices/4-004c/name:nct1008
/sys/bus/i2c/devices/i2c-0/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-1/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-2/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-3/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-4/name:Tegra I2C adapter

shell@android:/sys/kernel/debug # grep . clock/i2c*/rate                       
clock/i2c1/rate:3000000
clock/i2c2/rate:800000
clock/i2c3/rate:3000000



addresses from schematics

PWR_I2C address
PMU 0b0110_100 0x34
E-Compass 0b0000_110 0x06
Temperature sensor 0b0100_110 0x26
GEN1_I2C
Audio Codec 0b0011_010 0x1a
Light sensor 0b0001_110 0x0e
EC_SMB
BATT 0b0001_001 0x09
IME_I2C
G-sensor 0b0001_1111 0x1f

does g-sensor have typo? 0b0001_111 is 0x0f and we see such device

i2c devices support

memory

LPDDR: MT46H64M32L2JG-5IT-A_FBGA168

MT46H64M32L2CG-5 IT:A
2 x 1Gb DDR, x32, 200 MHz

64M32 - 64 Meg x 32 (8 Meg x 32 x 4 banks x 2)

Cycle Time: -5 = 5ns tCK CL = 3

permalink
esp8089

use esp8266 module over sdio on cubieboard as wifi card



links

    https://hackaday.io/project/8678-rpi-wifi-hat
    https://github.com/al177/esp8089

setup

cubieboard pinout

root@cubieboard:/home/dpavlin# cat mmc3-sdio.txt 
22 PI4 2 1 2 [mmc mmc3]                                SCD3_CMD
24 PI5 2 1 2 [mmc mmc3]                                SCD3_CLK
26 PI6 2 1 2 [mmc mmc3]                                SCD3_D0
28 PI7 2 1 2 [mmc mmc3]                                SCD3_D1
30 PI8 2 1 2 [mmc mmc3]                                SCD3_D2
32 PI9 2 1 2 [mmc mmc3]                                SCD4_D3

ESP-201 pinout from top

15 IO0                  13 IO15
14 IO2                  12 IO13
18 D2  GPIO9            10 IO12
21 CLK GPIO6            9  IO14
20 CMD GPIO11           8  XPD GPIO16
22 D0  GPIO7            7  CHIP_EN 
23 D1  GPIO8            32 RST
19 D3  GPIO10           6  TOUT ADC
16 IO4                  24 IO5
3.3V                    GND
3.3V                    GND

CH_EN mapping to GPIO pin

PE4   "132" => "PE4", -> CHIP_EN

root@cubieboard:/home/dpavlin/linux-gpio-pinout# modprobe esp8089 esp_reset_gpio=132 # PE4
[Sun Jun 30 19:19:24 2019] 
                           ***** EAGLE DRIVER VER:bdf5087c3deb*****

[Sun Jun 30 19:19:24 2019] ESP8089 reset via GPIO 132
[Sun Jun 30 19:19:35 2019] esp_sdio_init ------ RETRY ------ 
[Sun Jun 30 19:19:35 2019] ESP8089 reset via GPIO 132
[Sun Jun 30 19:19:35 2019] ESP8089 reset via GPIO 132
[Sun Jun 30 19:19:46 2019] esp_sdio_init ------ RETRY ------ 
[Sun Jun 30 19:19:46 2019] ESP8089 reset via GPIO 132
[Sun Jun 30 19:19:47 2019] ESP8089 reset via GPIO 132
[Sun Jun 30 19:19:58 2019] esp_sdio_init ------ RETRY ------ 
[Sun Jun 30 19:19:58 2019] ESP8089 reset via GPIO 132
[Sun Jun 30 19:19:58 2019] ESP8089 reset via GPIO 132
[Sun Jun 30 19:20:09 2019] esp_sdio_init ------ RETRY ------ 
[Sun Jun 30 19:20:09 2019] ESP8089 reset via GPIO 132
modprobe: ERROR: could not insert 'esp8089': No such device
[Sun Jun 30 19:20:10 2019] eagle sdio can not power up!


additional components

https://hackaday.io/project/8678-rpi-wifi/details

missing 200 ohm resistors on sdio lines

4.7k pullup on CH_PD https://github.com/al177/esp8089/issues/4

rpi needs dtoverlay=sdio,poll_once=false

it's still not clear to me do I have to remove spi flash or not

newer project with simpler overview

it suggests 33 ohm resistors on sdio, includes dts overlay)

https://hackaday.io/project/8678/instructions also suggest 33 ohm resistors...

clear the QE (quad enable) bit in the sreg2 of a W25Q40BV or similar

https://github.com/jacksonliam/rpi-bitbang-spiflash

bootloader

setup boudrate to 74880

anyboud.c

https://gist.githubusercontent.com/sentinelt/3f1a984533556cf890d9/raw/8a35958138b1167fce5c2301a73e2fe06aeb08d8/gistfile1.c

You have to first open terminal in some valid baud rate

root@cubieboard:~# microcom -p /dev/ttyS1

and then in another terminal force new speed for port with:

dpavlin@cubieboard:~/anybaud$ ./anyboud /dev/ttyS1 74880
Changed successfully.

boot modes

https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process#esp-boot-modes

The Espressif code can boot in different modes, selected on power-up based on GPIO pin levels. (MTDO is equivalent to GPIO15).

MTDO GPIO0 GPIO2 Mode Description
L L H UART Download code from UART
L H H Flash Boot from SPI Flash
H x x SDIO Boot from SD-card

In the bootup message 'boot mode:(x,y)' three low bits of x are {MTDO, GPIO0, GPIO2}.

IO15 -> 3V3

My guess from espressif powerpoint this is sdio boot mode (and it doesn't work for me right now)

 ets Jan  8 2013,rst cause:1, boot mode:(7,7)

waiting for host

IO15 -> GND

According to hackaday thread, this is correct way to force SDIO mode, serial output is:

 ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x40100000, len 31020, room 16

 ets Jan  8 2013,rst cause:1, boot mode:(3,7)

This seems like loading from spi flash to me. If I don't touch kernel module, but just toggle CH_EN pin

root@cubieboard:/home/dpavlin# cat esp-reset.sh
#!/bin/sh -xe

cd /sys/class/gpio/
echo 132 > export
echo out > gpio132/direction
echo 0 > gpio132/value
echo 1 > gpio132/value
echo 132 > unexport
root@cubieboard:/home/dpavlin# 

I get full bootloader output:

 ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x40100000, len 31020, room 16
tail 12
chksum 0x79
ho 0 tail 12 room 4
load 0x3ffe8000, len 2888, room 12
tail 12
chksum 0x6a
ho 0 tail 12 room 4
load 0x3ffe8b50, len 14864, room 12
tail 4
chksum 0x45
csum 0x45



It seems that esp tries to load first part, but fails and kernel module toggle CH_PD and resets it.
Time to try soldering resistors between 200 and 33 ohms I guess...

permalink
ESP8266


links

module_v2.png

  • all IO is 3.3V (3.6V max)
  • CH_PD i chip-enable and has to be connected to VCC (3.3V)
  • RST, GPIO0, GPIO2 should be pulled up to VCC for normal operation (GPIO0 at minumum!)
  • GPIO0 pull to ground for firmware update
  • make sure that 3.3V VCC power supply can support 300-400mA or there WILL be problems!

serial port

baud rate 115200

AT+GMR
00160901

OK

AT+RST

OK

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 24444, room 16 
tail 12
chksum 0xe0
ho 0 tail 12 room 4
load 0x3ffe8000, len 3168, room 12 
tail 4
chksum 0x93
load 0x3ffe8c60, len 4956, room 4 
tail 8
chksum 0xbd
csum 0xbd

ready


ESP-201

http://www.banggood.com/ESP8266-ESP-201-Remote-Serial-Port-WIFI-Transceiver-Wireless-Module-p-964288.html

ESP8266-ESP-201-pin-reference-v01.png

from http://smarpl.com/content/esp8266-esp-201-module-first-impressions

One quirk with the ESP-201 is that is IO15 has to be grounded for the device to function. To flash the device IO00 has to be grounded.

AT+RST

OK

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 212, room 16 
tail 4
chksum 0x5e
load 0x3ffe8000, len 788, room 4 
tail 0
chksum 0x1c
load 0x3ffe8314, len 72, room 8 
tail 0
chksum 0x55
csum 0x55
jump to user1


modify flash for dio instead of qio: http://smarpl.com/content/esp8266-esp-201-module-freeing-gpio9-and-gpio10

nodemcu

esptool.py

dpavlin@x200:/rest/cvs/esptool$ git remote -v
origin  https://github.com/themadinventor/esptool (fetch)
origin  https://github.com/themadinventor/esptool (push)

dpavlin@x200:/rest/cvs/esptool$ ./esptool.py --port /dev/ttyUSB2 read_mac
Connecting...
MAC: 18:fe:34:a0:38:72

flash firmware

dpavlin@blue:/opt/Espressif/esptool$ ./esptool.py read_mac
Connecting...
MAC: 18:fe:34:a0:38:72
dpavlin@blue:/opt/Espressif/esptool$ ./esptool.py --port /dev/ttyUSB0 write_flash 0x00000 ../nodemcu-firmware/pre_build/latest/nodemcu_latest.bin 
Connecting...
Erasing flash...
Writing at 0x00010800... (17 %) 

Get latest build from https://github.com/nodemcu/nodemcu-firmware/releases

dpavlin@x200:/rest/cvs/esptool$ ./esptool.py --port /dev/ttyUSB2 write_flash 0x00000 ./nodemcu_float_0.9.6-dev_20150406.bin

dpavlin@x200:/rest/cvs/esptool$ microcom -p /dev/ttyUSB2 -s 9600
connected to /dev/ttyUSB2
Escape character: Ctrl-\
Type the escape character followed by c to get to the menu or q to quit

> node.restart()

NodeMCU 0.9.6 build 20150406  powered by Lua 5.1.4
lua: cannot open init.lua
> 

build from source

For latest features, you might want to rebuild software from github source

dpavlin@x200:/rest/cvs$ git clone https://github.com/pfalcon/esp-open-sdk.git

dpavlin@x200:/rest/cvs/esp-open-sdk$ export PATH=/rest/cvs/esp-open-sdk/xtensa-lx106-elf/bin:$PATH




git clone https://github.com/nodemcu/nodemcu-firmware.git
cd nodemcu-firmware

dpavlin@x200:/rest/cvs/nodemcu-firmware$ git checkout -b dev origin/dev
Branch dev set up to track remote branch dev from origin.
Switched to a new branch 'dev'


make

# check that device is in boot loader mode

dpavlin@x200:/rest/cvs/nodemcu-firmware$ ../esptool/esptool.py --port /dev/ttyUSB1 read_mac
Connecting...
MAC: 18:fe:34:99:f2:83

# flash new firmware

dpavlin@x200:/rest/cvs/nodemcu-firmware$ make flash ESPPORT=/dev/ttyUSB1
make -C ./app flash
make[1]: Entering directory '/rest/cvs/nodemcu-firmware/app'
../tools/esptool.py --port /dev/ttyUSB1 write_flash 0x00000 ../bin/0x00000.bin 0x10000 ../bin/0x10000.bin
Connecting...
Erasing flash...
Writing at 0x0000c500... (100 %)
Erasing flash...
Writing at 0x00068c00... (100 %)

Leaving...
make[1]: Leaving directory '/rest/cvs/nodemcu-firmware/app'


A library for the Microchip MCP3021 A/D converter for use with the ESP8266.

https://github.com/AllAboutEE/ESP8266-MCP3021-Library

nodemcu-uploader

dpavlin@x200:/rest/cvs$ git clone https://github.com/kmpm/nodemcu-uploader
dpavlin@x200:/rest/cvs/nodemcu-uploader$ ./nodemcu-uploader.py --port /dev/ttyUSB2 --baud 9600 file list
Listing files
for key,value in pairs(file.list()) do print(key,value) end
> 

OpenOCD JTAG

https://github.com/projectgus/openocd

http://www.esp8266.com/viewtopic.php?f=9&t=1871#p11157

JTAG Signal -> ESP8266 GPIO Pin -> JTAG Pin (standard 20 pin connector)
TMS -> 14 -> 7
TDI -> 12 -> 5
TCK -> 13 -> 9
TDO -> 15 -> 13
RST -> RST -> 15

ESP8266 as wireless JTAG Programmer

https://github.com/emard/wifi_jtag

WIFI

software serial

Sonoff

https://www.itead.cc/sonoff-wifi-wireless-switch.html
http://wiki.iteadstudio.com/Sonoff
https://github.com/arendst/Sonoff-MQTT-OTA

pinout

My sonoff is early model, with just 4 pins (instead of 5)

1 - VCC
2 - RX
3 - TX
4 - GND

Programming

use dio not qio to fix checksum errors

CH340 USB to ESP8266 ESP-01 Wifi Module Adapter

It doesn't have GPIO0 connected to ground, so flashing doesn't work!

http://www.esp8266.com/wiki/doku.php?id=all-in-one-esp-usb-converter

ESP-01S DHT11 board

#define DHTTYPE DHT11
#define DHTPIN  2
DHT dht(DHTPIN, DHTTYPE, 11);

permalink
BeagleBone

BeagleBone Black



https://elinux.org/Beagleboard:BeagleBoneBlack

info

root@beaglebone:~# uname -a
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux
root@beaglebone:~# cat /proc/cpuinfo 
processor       : 0
model name      : ARMv7 Processor rev 2 (v7l)
BogoMIPS        : 297.40
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc08
CPU revision    : 2

Hardware        : Generic AM33XX (Flattened Device Tree)
Revision        : 0000
Serial          : 0000000000000000
root@beaglebone:~# cat /etc/issue
Angstrom v2012.12 - Kernel \r

serial

Board Cable
Pin 1 (GND) Black (GND)
Pin 4 (RX) Green (TX)
Pin 5 (TX) White (RX)

update board

dpavlin@nuc:/tmp$ xzcat bone-debian-9.3-iot-armhf-2018-01-28-4gb.img.xz | sudo dd of=/dev/sdc bs=1M

Insert SD card, press S2 USER/BOOT button to boot from SD card

https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Flashing_eMMC

root@beaglebone:~# uname -a
Linux beaglebone 4.9.78-ti-r94 #1 SMP PREEMPT Fri Jan 26 21:26:24 UTC 2018 armv7l GNU/Linux
root@beaglebone:~# cat /etc/issue
Debian GNU/Linux 9 \n \l

BeagleBoard.org Debian Image 2018-01-28


flash update to emmc

https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Flashing_eMMC

usb network

root@nuc:/home/dpavlin# ip link

8: enxd05fb8d1023b: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether d0:5f:b8:d1:02:3b brd ff:ff:ff:ff:ff:ff
9: enxd05fb8d1023e: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether d0:5f:b8:d1:02:3e brd ff:ff:ff:ff:ff:ff

root@beaglebone:~# ip addr
5: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d0:5f:b8:d1:02:3c brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.2/30 brd 192.168.7.3 scope global usb0
       valid_lft forever preferred_lft forever
    inet6 fe80::d25f:b8ff:fed1:23c/64 scope link 
       valid_lft forever preferred_lft forever
6: usb1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d0:5f:b8:d1:02:3f brd ff:ff:ff:ff:ff:ff
    inet 192.168.6.2/30 brd 192.168.6.3 scope global usb1
       valid_lft forever preferred_lft forever
    inet6 fe80::d25f:b8ff:fed1:23f/64 scope link 
       valid_lft forever preferred_lft forever

# matchs IP addresses to find out which interface on bbb is which on nuc (mac on nuc is one less than bbb), so

root@nuc:/home/dpavlin# ifconfig enxd05fb8d1023b 192.168.7.1
root@nuc:/home/dpavlin# ping -c 1 192.168.7.2
PING 192.168.7.2 (192.168.7.2) 56(84) bytes of data.
64 bytes from 192.168.7.2: icmp_seq=1 ttl=64 time=0.817 ms

--- 192.168.7.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.817/0.817/0.817/0.000 ms

# nat bbb

root@nuc:/home/dpavlin# iptables -t nat -A POSTROUTING -s 192.168.7.0/30 -o eth0 -j MASQUERADE

dpavlin@nuc:~$ ssh debian@192.168.7.2
debian@192.168.7.2's password: 
Linux beaglebone 4.9.78-ti-r94 #1 SMP PREEMPT Fri Jan 26 21:26:24 UTC 2018 armv7l

root@beaglebone:/home/debian# ip route add default via 192.168.7.1
root@beaglebone:/home/debian# ip route add default via 192.168.7.1
root@beaglebone:/home/debian# cat /etc/resolv.conf 
nameserver 8.8.8.8
root@beaglebone:/home/debian# ping -c 1 www.google.com
PING www.google.com (172.217.21.100) 56(84) bytes of data.
64 bytes from fra07s32-in-f100.1e100.net (172.217.21.100): icmp_seq=1 ttl=51 time=30.4 ms

--- www.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 30.460/30.460/30.460/0.000 ms


PRU

http://ianrrees.github.io/2016/11/20/getting-started-with-beaglebone-pru-programming-the-new-way.html

permalink
Ubertooth One
ubertooth-specscan-ui.png

https://greatscottgadgets.com/ubertoothone/

https://github.com/greatscottgadgets/ubertooth

dpavlin@nuc:~$ lsusb -d 1d50:6002
Bus 002 Device 015: ID 1d50:6002 OpenMoko, Inc. Ubertooth One

install

https://github.com/greatscottgadgets/ubertooth/wiki/Build-Guide

dpavlin@nuc:~$ sudo apt install ubertooth

dpavlin@nuc:~$ sudo ubertooth-util -vV
Firmware version: 2012-10-R1 (API:1.00)
control message unsupported
error: -9

very old firmware, let's upgrade it

dpavlin@nuc:~$ sudo ubertooth-dfu -d /usr/share/ubertooth/firmware/bluetooth_rxtx.dfu -r
libUSB Error: Input/Output Error:  (-1)
Switching to DFU mode...
Checking firmware signature
........................................
........................................
........................................

libUSB Error: Input/Output Error:  (-1


reset failed, plugin out, plug in

dpavlin@nuc:~$ sudo ubertooth-util -vV
Firmware version: 2018-12-R1 (API:1.06)
ubertooth 2018-12-R1 (user@localhost) 

usage

dpavlin@nuc:~$ ubertooth-specan-ui 

permalink
INA3221
ina3221.pdf

OUT INA3221 KACITRAN.jpg



i2c addresses

When I had more than one module, it was necessary to add solder bridges on all modules (even default gnd one) to make than all work, otherwise 0x40 won't work reliably.

all grounds tied together, single input voltage

I have two versions of this modules purple and black, and they seem to have same problem:

Alternative source with better pictures of modifications for multi-voltage support:

simplest modifications with just three holes and three wires

ina3221-800px.jpg

Cutting traces on both sides of board seemed like too much for me, so I decided to use hand drill to scratch top side of board at three places
and disconnect ground and power input from resistors. Add three wires to connect new pin to connect load to or just connect any dupont wire
to use it as 10-bit voltage adc.

Linux setup

root@cubieboard:/home/dpavlin# modinfo ina3221
filename:       /lib/modules/4.19.25-sunxi/kernel/drivers/hwmon/ina3221.ko
license:        GPL v2
description:    Texas Instruments INA3221 HWMon Driver
author:         Andrew F. Davis <afd@ti.com>
alias:          of:N*T*Cti,ina3221C*
alias:          of:N*T*Cti,ina3221
alias:          i2c:ina3221
depends:
intree:         Y
name:           ina3221
vermagic:       4.19.25-sunxi SMP mod_unload ARMv7 thumb2 p2v8

root@cubieboard:/home/dpavlin# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@cubieboard:/home/dpavlin# echo ina3221 0x40 > /sys/bus/i2c/devices/i2c-2/new_device 
[Sun May 12 14:23:20 2019] i2c i2c-2: new_device: Instantiated device ina3221 at 0x40

root@cubieboard:/home/dpavlin# sensors
pcf8591-i2c-2-48
Adapter: mv64xxx_i2c adapter
in0:          +2.13 V  
in1:          +2.55 V  
in2:          +0.01 V  
in3:          +1.32 V  

ina3221-i2c-2-40
Adapter: mv64xxx_i2c adapter
in1:          +0.02 V  
in2:          +0.02 V  
in3:          +0.02 V  
in4:          +0.00 V  
in5:          +0.00 V  
in6:          +0.00 V  
curr1:        +0.00 A  (max = +16.38 A, crit max = +16.38 A)
curr2:        +0.00 A  (max = +16.38 A, crit max = +16.38 A)
curr3:        +0.00 A  (max = +16.38 A, crit max = +16.38 A)

# setup correct resistors:

root@cubieboard:/home/dpavlin# grep -A 2 ina3221 /etc/rc.local
echo ina3221 0x40 > /sys/bus/i2c/devices/i2c-2/new_device
sleep 1
ls /sys/devices/platform/soc/*.i2c/i2c-2/2-0040/hwmon/hwmon1/shunt*_resistor | xargs -i sh -cx 'echo 100000 > {}'


permalink
PCA9685
PCA9685.pdf

PCA9685.jpg

16-channel, 12-bit PWM Fm+ I 2 C-bus LED controller

dpavlin@cubieboard:~$ zgrep 9685 /proc/config.gz 
CONFIG_PWM_PCA9685=m

# on armbian this requires kernel recompile

root@cubieboard:~# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: UU UU -- UU -- -- -- -- UU -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: 70 -- -- -- -- -- -- --                         

root@cubieboard:~# echo pca9685 0x70 > /sys/bus/i2c/devices/i2c-2/new_device 
[Tue Jun 25 19:59:58 2019] i2c i2c-2: new_device: Instantiated device pca9685 at 0x70

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0# echo 0 > export

# Default period_ns = 1/200 Hz
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 5000000 > period 
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# cat period 
5000000
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# cat duty_cycle 
0

# move servo

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 2000000 > duty_cycle 
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 1000000 > duty_cycle 

sg90 servo motor

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 20000000 > period # 50Hz

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 1000000 > duty_cycle # min?

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 3000000 > duty_cycle # max?



permalink
CubieBoard
cubieboard-ir-module.png

cubieboard_schematic_2012-08-08.pdf

BreadBoard V1.0 03-25 For CubieBoard.pdf

Contents: [Dobrica Pavlinušić's random unstructured stuff]


A20

Running UBI/UBIFS on MLC NAND

NAND in mainline kernel

Samsung K9GBG08U0A NAND

dpavlin@cubieboard:~$ dmesg | grep -A 5 nand
[    4.395437] nand: Could not find valid JEDEC parameter page; aborting
[    4.401898] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xd7
[    4.408272] nand: Samsung NAND 4GiB 3,3V 8-bit
[    4.412719] nand: 4096 MiB, MLC, erase size: 1024 KiB, page size: 8192, OOB size: 640
[    4.421299] Bad block table found at page 524160, version 0x25
[    4.427987] Bad block table found at page 524032, version 0x25
[    4.434238] nand_read_bbt: bad block at 0x000001000000
[    4.439379] nand_read_bbt: bad block at 0x000001100000
[    4.445411] 6 ofpart partitions found on MTD device 1c03000.nand
[    4.451420] Creating 6 MTD partitions on "1c03000.nand":
[    4.456769] 0x000000a00000-0x0001ffa00000 : "rootfs"
[    4.461737] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[    4.472910] 0x000001000000-0x000001400000 : "env"
[    4.477926] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[    4.483748] 0x000000800000-0x000000c00000 : "U-Boot"
[    4.488997] 0x000000400000-0x000000800000 : "SPL.backup"
[    4.494580] 0x000000000000-0x000000400000 : "SPL"



dpavlin@cubieboard2:~$ dmesg | grep -A 5 nand
[    4.709427] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xd7
[    4.715876] nand: Hynix H27UBG8T2BTR-BC 32G 3.3V 8-bit
[    4.721021] nand: 4096 MiB, MLC, erase size: 2048 KiB, page size: 8192, OOB size: 640
[    4.728997] Scanning device for bad blocks
[    8.484659] 6 ofpart partitions found on MTD device 1c03000.nand
[    8.490678] Creating 6 MTD partitions on "1c03000.nand":
[    8.496021] 0x000000a00000-0x0001ffa00000 : "rootfs"
[    8.500992] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[    8.515527] 0x000001000000-0x000001400000 : "env"
[    8.520564] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[    8.526504] 0x000000800000-0x000000c00000 : "U-Boot"
[    8.531755] 0x000000400000-0x000000800000 : "SPL.backup"
[    8.537395] 0x000000000000-0x000000400000 : "SPL"

many bad blocks

http://linux-sunxi.org/Mainline_NAND_Howto#Many_bad_blocks

To fix many bad blocks issue you should:

1. Disable nand-on-flash-bbt in your dts
2. Remove this test: http://lxr.free-electrons.com/source/drivers/mtd/nand/nand_base.c?v=4.7#L2940
3. Boot your new kernel and erase chip with flash_erase /dev/mtd[0-X]
4. Re-introduce the bad block check removed in 2, re-enable nand-on-flash-bbt
   and boot the new kernel

Let's try to do this with armbian.

cubieboard

First, enable nand overlay

dpavlin@cubieboard:~$ cat /boot/armbianEnv.txt
overlays=nand

Then remove nand-om-flash-btt:

dpavlin@cubieboard:/$ cd /boot/dtb-`uname -r`/overlay
dpavlin@cubieboard:/boot/dtb-4.14.23-sunxi/overlay$ 

# backup original
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# cp sun4i-a10-nand.dtbo sun4i-a10-nand.dtbo.orig

# remote nand-on-flash-bbt
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# dtc -I dtb -O dts sun4i-a10-nand.dtbo | grep -v nand-on-flash-bbt > /tmp/nand.dts
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# dtc -I dts -O dtb /tmp/nand.dts > sun4i-a10-nand.dtbo

Compile armbian kernel with this patch applied

dpavlin@armbian:~/build$ cp ./patch/kernel/sunxi-dev/nand-disable-badblock-check-for-migration.patch.disabled \
    ./userpatches/kernel/sunxi-next/nand-disable-badblock-check-for-migration.patch

Reboot and check that nand is available:

dpavlin@cubieboard:~$ dmesg | grep -A 8 MTD
[   13.696198] 6 ofpart partitions found on MTD device 1c03000.nand
[   13.702205] Creating 6 MTD partitions on "1c03000.nand":
[   13.707550] 0x000000a00000-0x0001ffa00000 : "rootfs"
[   13.712517] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[   13.723693] 0x000001000000-0x000001400000 : "env"
[   13.728713] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[   13.734568] 0x000000800000-0x000000c00000 : "U-Boot"
[   13.739778] 0x000000400000-0x000000800000 : "SPL.backup"
[   13.745368] 0x000000000000-0x000000400000 : "SPL"
[   13.751476] sun4i-mdio 1c0b080.mdio: 1c0b080.mdio supply phy not found, using dummy regulator

Now init nand:

root@cubieboard:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 1048576 (1M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0


root@cubieboard2:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 2097152 (2M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0

root@cubieboard:/home/dpavlin# flash_erase /dev/mtd0 0 0
Erasing 1024 Kibyte @ 600000 --  0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 6 (mtd0)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd0: MTD Erase failure
             error 5 (Input/output error)
Erasing 1024 Kibyte @ 700000 --  0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 7 (mtd0)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd0: MTD Erase failure
             error 5 (Input/output error)
Erasing 1024 Kibyte @ ff500000 -- 100 % complete 


root@cubieboard:/home/dpavlin# ubiformat /dev/mtd0
ubiformat: mtd0 (mlc-nand), size 4284481536 bytes (4.0 GiB), 4086 eraseblocks of 1048576 bytes (1024.0 KiB), min. I/O size 8192 bytes
libscan: scanning eraseblock 4085 -- 100 % complete  
ubiformat: 4084 eraseblocks are supposedly empty
ubiformat: warning!: 2 of 4086 eraseblocks contain non-UBI data
ubiformat: continue? (y/N) y
ubiformat: warning!: only 0 of 4086 eraseblocks have valid erase counter
ubiformat: erase counter 0 will be used for all eraseblocks
ubiformat: note, arbitrary erase counter value may be specified using -e option
ubiformat: continue? (y/N) y
ubiformat: use erase counter 0 for all eraseblocks
ubiformat: formatting eraseblock 6 --  0 % complete  libmtd: error!: MEMERASE64 ioctl failed for eraseblock 6 (mtd0)
        error 5 (Input/output error)

ubiformat: error!: failed to erase eraseblock 6
           error 5 (Input/output error)
ubiformat: mark it as bad? (y/N) y
ubiformat: marking block 6 bad
ubiformat: formatting eraseblock 7 --  0 % complete  libmtd: error!: MEMERASE64 ioctl failed for eraseblock 7 (mtd0)
        error 5 (Input/output error)

ubiformat: error!: failed to erase eraseblock 7
           error 5 (Input/output error)
ubiformat: mark it as bad? (y/N) y
ubiformat: marking block 7 bad
ubiformat: formatting eraseblock 4085 -- 100 % complete  




ubiattach -p /dev/mtd0

ubimkvol /dev/ubi0 -s 2GiB -N root

mount /dev/ubi0_0 /mnt/ -t ubifs

root@cubieboard:~# mount /dev/ubi0_0 /mnt/ -t ubifs
[Wed Feb 28 17:49:38 2018] UBIFS error (pid: 4709): cannot open "/dev/ubi0:root", error -22
[Wed Feb 28 17:49:43 2018] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 4722
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "root"
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): LEB size: 1032192 bytes (1008 KiB), min./max. I/O unit sizes: 8192 bytes/8192 bytes
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): FS size: 2137669632 bytes (2038 MiB, 2071 LEBs), journal size 33030144 bytes (31 MiB, 32 LEBs)
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 8E9A30F0-241F-4013-916F-C0B995F22BB1, small LPT model


cubieboard2

This is mostly redundant from cubieboard, but with attempt to define mtd partitions correctly

root@cubieboard2:/home/dpavlin# ubiformat /dev/mtd0
ubiformat: mtd0 (mlc-nand), size 4273995776 bytes (4.0 GiB), 2038 eraseblocks of 2097152 bytes (2.0 MiB), min. I/O size 8192 bytes
libscan: scanning eraseblock 2037 -- 100 % complete  
ubiformat: 2038 eraseblocks have valid erase counter, mean value is 1
ubiformat: formatting eraseblock 2037 -- 100 % complete  



mount ubifs filesystem

dpavlin@cubieboard:~$ grep ubi /mnt/boot/armbianEnv.txt
rootdev=ubi0:root ubi.mtd=0
rootfstype=ubifs

dpavlin@cubieboard:~$ grep ubi /etc/fstab 
ubi0:root / ubifs defaults,noatime,nodiratime 0 1

u-boot

Original u-boot output

HELLO! BOOT0 is starting!
boot0 version : 1.5.1
dram size =1024
Succeed in opening nand flash.
Succeed in reading Boot1 file head.
The size of Boot1 is 0x0003c000.
The file stored in 0X00000000 of block 2 is perfect.
Check is correct.
Ready to disable icache.
Succeed in loading Boot1.
Jump to Boot1.
[       0.133] boot1 version : 1.4.0
[       0.133] pmu type = 3
[       0.134] bat vol = 0
[       0.161] axi:ahb:apb=3:2:2
[       0.161] set dcdc2=1400, clock=1008 successed
[       0.163] key
[       0.175] no key found
[       0.175] flash init start
[       4.051] flash init finish
[       4.052] fs init ok
[       4.053] fattype FAT16
[       4.053] fs mount ok
[       4.060] script finish
[       4.061] power finish
[       4.069] BootMain start
[       4.069] 13
[       4.089] key value = 0
[       4.089] recovery key high 6, low 4
[       4.090] unable to find fastboot_key key_max value
[       4.098] test for multi os boot with display
[       4.100] show pic finish
[       4.103] load kernel start
[       4.127] load kernel successed
[       4.127] start address = 0x4a00000

U-Boot 2011.09-rc1 (Nov 26 2012 - 14:01:52) Allwinner Technology 

CPU:   SUNXI Family
Board: A10-EVB
DRAM:  512 MiB
NAND:  3776 MiB
In:    serial
Out:   serial
Err:   serial
--------fastboot partitions--------
-total partitions:11-
-name-        -start-       -size-      
bootloader  : 1000000       1000000     
env         : 2000000       1000000     
boot        : 3000000       2000000     
system      : 5000000       14000000    
data        : 19000000      20000000    
misc        : 39000000      1000000     
recovery    : 3a000000      2000000     
cache       : 3c000000      8000000     
private     : 44000000      1000000     
sysrecovery : 45000000      14000000    
UDISK       : 59000000      93000000    
-----------------------------------
Hit any key to stop autoboot:  0 
sunxi#

compile with nand support

On Cubieboard2 with those patches we get:

=> nand info

Device 0: nand0, sector size 2048 KiB
  Page size       8192 b
  OOB size         640 b
  Erase size   2097152 b
  subpagesize     8192 b
  options     0x00001000
  bbt options 0x00070000

# which comparted to booted linux kernel with mtd support....

root@cubieboard2:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 2097152 (2M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0

# it looks somewhat OK, but mtdparts doesn't (yet) return anything.

Another day, another try to get mtdparts to display something...

root@armbian:~/build/cache/sources/u-boot/v2017.11# grep -i mtd .config
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTDIDS_DEFAULT="nand0=sunxi-nand"
CONFIG_MTDPARTS_DEFAULT="mtdparts=sunxi-nand:4m(spl),4m(spl-backup),4m(uboot),4m(uboot-backup),4m(env),-(UBI)"
# CONFIG_CMD_MTDPARTS_SPREAD is not set
# MTD Support
CONFIG_MTD=y
# CONFIG_MTD_NOR_FLASH is not set
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
# CONFIG_MTD_UBI_FASTMAP is not set

=> mtdparts

device nand0 <sunxi-nand>, # parts = 6
 #: name                size            offset          mask_flags
 0: spl                 0x00400000      0x00000000      0
 1: spl-backup          0x00400000      0x00400000      0
 2: uboot               0x00400000      0x00800000      0
 3: uboot-backup        0x00400000      0x00c00000      0
 4: env                 0x00400000      0x01000000      0
 5: UBI                 0xfec00000      0x01400000      0

active partition: nand0,0 - (spl) 0x00400000 @ 0x00000000

defaults:
mtdids  : nand0=sunxi-nand
mtdparts: mtdparts=sunxi-nand:4m(spl),4m(spl-backup),4m(uboot),4m(uboot-backup),4m(env),-(UBI)







Instructions after this are hit-or-miss...

dpavlin@klin:/klin/u-boot$ cp configs/Cubieboard_defconfig .config

# add NAND, MTD options, A10 for cubieboard1

# compile while defining flash:

dpavlin@klin:/klin/u-boot$ cat build-cubieboard.sh 
# parametars are probably wrong for your chip!
make V=1 CONFIG_NAND_SUNXI_SPL_ECC_STRENGTH=40 CONFIG_SYS_NAND_PAGE_SIZE=4036 CONFIG_SYS_NAND_OOBSIZE=640 CONFIG_SYS_NAND_BLOCK_SIZE=0x100000


dpavlin@cubieboard:~$ scp 10.60.0.92:/klin/u-boot/u-boot*spl* .

dpavlin@cubieboard:~$ sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8 
488+1 records in
488+1 records out
500154 bytes (500 kB) copied, 0.0423498 s, 11.8 MB/s


It would be better to define params in u-boot config file like:

CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCK_SIZE=0x40000,SYS_NAND_PAGE_SIZE=4096,SYS_NAND_OOBSIZE=256"

(with correct values of course).

pinout

U14 (Next to SATA connector)

  SPI0
48 PI13 (SPI0-MISO/UART6-RX/EINT25) 47 PI11 (SPI0-CLK/UART5-RX/EINT23)
46 PI12 (SPI0-MOSI/UART6-TX/EINT24) 45 PI10 (SPI0-CS/UART5-TX/EINT22)
  LCD
44 3.3V (nc in 2012-08-08) 43 VCC-5V
42 Ground 41 SPDIF
40 PB10 (LCD0-SCK/LCD-PIO1) 39 PB11 (LCD0-SDA/LCD-PIO2)
38 Ground 37 PH7 (LCD0-BL-EN/LCD-PIO0/UART5-RX/EINT7)
36 XN_TP (TP-X2) 35 YN_TP (TP-Y2)
34 XP_TP (TP-X1) 33 YP_TP (TP-Y1)
32 PD25 (LCDDE) 31 PB2 (PWM0)
30 PD26 (LCDHSYNC)-VGA-HSYNC 29 PD24 (LCDCLK)
28 PD23 (LCDD23) 27 PD27 (LCDVSYNC)-VGA-VSYNC
26 PD21 (LCDD21) 25 PD22 (LCDD22)
24 PD19 (LCDD19/LVDS1N3) 23 PD20 (LCDD20)
22 PD17 (LCDD17/LVDS1NC) 21 PD18 (LCDD18/LVDS1P3)
20 Ground 19 PD16 (LCDD16/LVDS1PC)
18 PD14 (LCDD14/LVDS1P2) 17 PD15 (LCDD15/LVDS1N2)
16 PD12 (LCDD12/LVDS1P1) 15 PD13 (LCDD13/LVDS1N1)
14 PD10 (LCDD10/LVDS1P0) 13 PD11 (LCDD11/LVDS1N0)
12 PD8 (LCDD8/LVDS0P3) 11 PD9 (LCDD9/LVDS0N3)
10 PD7 (LCDD7/LVDS0NC) 9 Ground
8 PD5 (LCDD5/LVDS0N2) 7 PD6 (LCDD6/LVDS0PC)
6 PD3 (LCDD3/LVDS0N1) 5 PD4 (LCDD4/LNVS0P2)
4 PD1 (LCDD1/LVDS0N0) 3 PD2 (LCDD2/LVDS0P1)
2 Ground 1 PD0 (LCDD0/LVDSP0)

U15 (Between Ethernet port and USB ports)

  CSI1/TS
1 VCC-5V 2 PH15 (CSI1-PWR/EINT15)
3 CSI1-IO-2V8 4 PH14 (CSI1-RST#/EINT14)
5 PG0 (CSI1-PCLK/SDC1-CMD) 6 PB18 (TWI1-SCK)
7 PB19 (TWI1-SDA) 8 PG3 (CSI1-VSYNC/SDC1-D1)
9 PG2 (CSI1-HSYNC/SDC1-D0) 10 PG1 (CSI1-MCLK/SDC1-CLK)
11 PG4 (CSI1-D0/SDC1-D2) 12 PG5 (CSI1-D1/SDC1-D3)
13 PG6 (CSI1-D2/UART3-TX) 14 PG7 (CSI1-D3/UART3-RX
15 PG8 (CSI1-D4/UART3-RTS) 16 PG9 (CSI1-D5/UART3-CTS)
17 PG10 (CSI1-D6/UART4-TX) 18 PG11 (CSI1-D7/UART4-RX)
19 Ground 20 Ground
  Analog SDIO3
21 FMINL 22 PI4 (SDC3-CMD)
23 FMINR 24 PI5 (SDC3-CLK)
25 Ground 26 PI6 (SDC3-D0)
27 VGA-R 28 PI7 (SDC3-D1)
29 VGA-G 30 PI8 (SDC3-D2)
31 VGA-B 32 PI9 (SDC3-D3)
  CSI0/TS
33 LCD1-VSYNC 34 PE4 (CSI0-D0)
35 LCD1-HSYNC 36 PE5 (CSI0-D1)
37 Ground 38 PE6 (CSI0-D2)
39 AVCC 40 PE7 (CSI0-D3)
41 LRADC0 42 PE8 (CSI0-D4)
43 CVBS 44 PE9 (CSI0-D5)
45 HPL 46 PE10 (CSI0-D6)
47 HPR 48 PE11 (CSI0-D7)


everything below line is for legacy kernel and quite old

disk speed

NAND

root@cubieboard2:/home/dpavlin# uname -a
Linux cubieboard2 3.4.109-sun7i #4 SMP PREEMPT Sun Oct 11 14:32:15 CEST 2015 armv7l GNU/Linux
root@cubieboard2:/home/dpavlin# hdparm -t /dev/nand

/dev/nand:
 Timing buffered disk reads:  32 MB in  3.22 seconds =   9.94 MB/sec

# this is different, faster sdcard
root@cubieboard2:~# uname -a
Linux cubieboard2 4.3.3-sunxi #3 SMP Mon Dec 28 11:27:16 CET 2015 armv7l GNU/Linux
root@cubieboard2:~# hdparm -tT /dev/mmcblk0

/dev/mmcblk0:
 Timing cached reads:   770 MB in  2.00 seconds = 384.59 MB/sec
 Timing buffered disk reads:  60 MB in  3.05 seconds =  19.67 MB/sec



SATA

Powered by 2A Nexus 7 power supply (for SATA)

https://groups.google.com/d/searchin/cubieboard/sata/cubieboard/hKJgJneGVmQ/xme3w4Y7XtsJ?fromplusone=1

root@debian:~/sunxi-tools# ./bin2fex /boot/script.bin script.fex
fexc-bin: /boot/script.bin: version: 0.1.2
fexc-bin: /boot/script.bin: size: 42144 (76 sections)

root@debian:~/sunxi-tools# cp script.fex script+sata.fex

root@debian:~/sunxi-tools# diff -urw script.fex script+sata.fex 
--- script.fex  2013-05-30 10:41:13.979510762 +0000
+++ script+sata.fex     2013-05-30 10:42:36.380244101 +0000
@@ -595,7 +595,7 @@
 
 [sata_para]
 sata_used = 1
-sata_power_en =
+sata_power_en = port:PB08<1><default><default><0>
 
 [mmc0_para]
 sdc_used = 1

root@debian:~/sunxi-tools# ./fex2bin script+sata.fex /boot/script.bin

root@debian:/etc# git diff
diff --git a/modules b/modules
index d8894c3..9e65a80 100644
--- a/modules
+++ b/modules
@@ -4,3 +4,4 @@
 # at boot time, one per line. Lines beginning with "#" are ignored.
 # Parameters can be specified after the module name.
 
+sw_ahci_platform

Reboot to activate changes and test speed (using 80G intel SSD to have sense of maximum performance)

root@debian:~# hdparm -i /dev/sda

/dev/sda:

 Model=INTEL SSDSA2M080G2GC, FwRev=2CV102HD, SerialNo=CVPO035101VN080JGN
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=1
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: ATA/ATAPI-7 T13 1532D revision 1:  ATA/ATAPI-2,3,4,5,6,7

 * signifies the current active mode

root@debian:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   784 MB in  2.00 seconds = 392.08 MB/sec
 Timing buffered disk reads: 460 MB in  3.00 seconds = 153.32 MB/sec

And test with disk:

root@debian:~# hdparm -i /dev/sda

/dev/sda:

 Model=ST96812AS, FwRev=7.24, SerialNo=3PJ1GCKE
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=off
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=117231408
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-1,2,3,4,5,6,7

 * signifies the current active mode

root@debian:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   746 MB in  2.00 seconds = 372.90 MB/sec
 Timing buffered disk reads: 120 MB in  3.03 seconds =  39.56 MB/sec

GPIO

Camera

OV7670 is supported http://linux-sunxi.org/CSI

hardware

pinout: gpio_defination_large.jpg

https://www.olimex.com/wiki/How_to_add_pwm

cat /sys/class/pwm-sunxi/pwm0/pin 
PB2

echo 10khz > /sys/class/pwm-sunxi/pwm0/period

echo 25 > /sys/class/pwm-sunxi/pwm0/duty_percent

echo 1 > /sys/class/pwm-sunxi/pwm0/run

LEDs

dpavlin@cubieboard2:~$ grep . /sys/class/leds/*/trigger 
/sys/class/leds/blue:ph21:led2/trigger:none battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer [heartbeat] backlight cpu0 cpu1 default-on 
/sys/class/leds/green:ph20:led1/trigger:[none] battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer heartbeat backlight cpu0 cpu1 default-on 

forum

ina219

device tree

dpavlin@cubieboard2:~$ sensors
ina219-i2c-1-40
Adapter: mv64xxx_i2c adapter
in0:          +0.04 V  
in1:          +4.64 V  
power1:       66.88 W  
curr1:       +13.64 A  

iio_hwmon-isa-0000
Adapter: ISA adapter
temp1:        +33.6�C  

root@cubieboard2:~# dmesg | grep ina | tail -1
[ 6597.685287] ina2xx 1-0040: power monitor ina219 (Rshunt = 100 uOhm)

# hum, it should be 10uA, so I changed that in device tree

dpavlin@cubieboard2:~$ dmesg | grep ina219
[   11.594536] ina2xx 1-0040: power monitor ina219 (Rshunt = 10 uOhm)
dpavlin@cubieboard2:~$ sensors
ina219-i2c-1-40
Adapter: mv64xxx_i2c adapter
in0:          +0.02 V  
in1:          +4.75 V  
power1:       85.00 W  
curr1:       +17.97 A  

iio_hwmon-isa-0000
Adapter: ISA adapter
temp1:        +32.5�C  

# still wrong current!


user-land C

User-land implementation which works: https://github.com/ZigFisher/Glutinium/blob/master/i2c-telemetry/src/ina219.c

modified a little to provide full timestamp and fflush: ina219.c

dpavlin@cubieboard2:~$ ./ina219 -b 1 -i 1
2017-10-23T12:40:24 4744mV  262.2mA
2017-10-23T12:40:26 4756mV  249.1mA
2017-10-23T12:40:27 4776mV  223.0mA
2017-10-23T12:40:28 4772mV  223.8mA
2017-10-23T12:40:29 4760mV  224.0mA
2017-10-23T12:40:30 4768mV  223.0mA
2017-10-23T12:40:31 4772mV  223.1mA
2017-10-23T12:40:32 4748mV  224.6mA
2017-10-23T12:40:33 4776mV  223.1mA
2017-10-23T12:40:34 4768mV  223.5mA

SPI flash

flashrom

dpavlin@cubieboard:~$ sudo grep spidev /boot/armbianEnv.txt
overlays=pwm nand uart3 uart4 spi-spidev
#overlays=spi-spidev
param_spidev_spi_bus=0


dpavlin@cubieboard:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0
flashrom v0.9.9-2-g51e4303 on Linux 4.14.47-sunxi (armv7l)
flashrom is free software, get the source code at https://flashrom.org

Calibrating delay loop... OK.
Found GigaDevice flash chip "GD25Q80(B)" (1024 kB, SPI) on linux_spi.
No operations were specified.

root@cubieboard:/home/dpavlin# time flashrom -p linux_spi:dev=/dev/spidev0.0 -r /dev/null
flashrom v0.9.9-2-g51e4303 on Linux 4.14.47-sunxi (armv7l)
flashrom is free software, get the source code at https://flashrom.org

Calibrating delay loop... OK.
Found GigaDevice flash chip "GD25Q80(B)" (1024 kB, SPI) on linux_spi.
Reading flash... done.

real    0m11.210s
user    0m0.796s
sys     0m0.381s


build u-boot with SPI support

http://linux-sunxi.org/Bootable_SPI_flash

git clone -b sunxi-spi https://github.com/StephanvanSchaik/u-boot

dpavlin@armbian:~/u-boot$ git diff
diff --git a/configs/Cubieboard_defconfig b/configs/Cubieboard_defconfig
index 0389d4c..cbafac9 100644
--- a/configs/Cubieboard_defconfig
+++ b/configs/Cubieboard_defconfig
@@ -16,3 +16,13 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_USB_EHCI_HCD=y
+
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_DM_SPI=y
+CONFIG_SUNXI_SPI=y
+
dpavlin@armbian:~/u-boot$ make Cubieboard_defconfig




This doesn't actually work for me (since it's missing device tree overlays), but rebasing to current u-boot master doesn't
produce code which compiles.

https://forum.armbian.com/topic/3252-opi-zero-boot-with-spi/

reset

http://linux-sunxi.org/Cubieboard/Reset

external ir receiver

configuration described on lirc page

permalink
Weblog Navigation
Loading...
Weblog Archives
  • Loading...