Quick jump:  What's new

 
Go to:
 
Weblog: Recent Changes   
in Dobrica Pavlinušić's random unstructured stuff
Fabrikator II mini

Links that I collected while trying it out...



If you know Croatian, start here: http://radiona.org/wiki/inventory/fabrikator_2_mini
to configure wifi and get web interface working

M550 SSID
M551 PaSsWoRd

# verify IP from ap
M552

tools

g-code

https://marlinfw.org/docs/gcode/M018.html

Disable all steppers immediately

M18

schematics

software

dpavlin@nuc:/nuc/Fabrikator_ii_mini$ sudo apt install repetier-host


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


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

verified on https://visualgdb.com/tutorials/esp8266/nodemcu/jtag/

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);

adding IR led

Button is connected to RST, and if you want to add IR led (with transistor and resistor) it seems that only
way to make it work is to connect it to RX pin (gpio3). For more info see my blog post: https://blog.rot13.org/2019/08/emulate-ir-remote-for-tv-or-hvac-from-command-line-using-tasmota.html

KEYESTUDIO ESP8266 ESP-12F CH340G WiFi Module Board for Arduino NodeMcu

https://www.keyestudio.com/products/new-keyeastudio-nodemcu-lua-esp8266-esp-12f-wifi-module-1m-usb-cable-development-board-compatible-with-networking

keyes-esp8266-pinout.jpg
permalink
micropython


esptool and raspberry pi

I found out that older versions of esptool (like the ones deliveved by debian packages) don't work well on raspberry pi 2 and raspberry pi 4

root@pihdmi:/home/pi/linux-gpio-pinout# esptool -p /dev/ttyUSB0 read_mac
esptool.py v2.5.1
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header

root@pihdmi:/home/pi/linux-gpio-pinout# /nuc/esp32/esptool/esptool.py --port /dev/ttyUSB0 read_mac
esptool.py v3.2-dev
Serial port /dev/ttyUSB0
Connecting........_____....._____.....___
Detecting chip type... ESP32
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: a4:cf:12:55:c5:60
Uploading stub...
Running stub...
Stub running...
MAC: a4:cf:12:55:c5:60
Hard resetting via RTS pin...

esp-idf version

dpavlin@nuc:/nuc/esp32/esp-idf$ git remote -v
origin  https://github.com/espressif/esp-idf.git (fetch)
origin  https://github.com/espressif/esp-idf.git (push)

dpavlin@nuc:/nuc/esp32/esp-idf$ git checkout -b v3.3-upy 9e70825d1e1cbf7988cf36981774300066580ea7
dpavlin@nuc:/nuc/esp32/esp-idf$ git submodule update --init --recursive

For latest micropython v4.3 leaves too little memory available for esp32ecp/ecp5

v4.2.2

( 'gc', gc.isenabled(), 'alloc', gc.mem_alloc(), 'free', gc.mem_free() )
gc True alloc 25632 free 85536

enough memory, but 50% packet loss for ping to remote ppp ip

v4.1.1 doesn't have ip_napt_enable

test alternative lwip lib

dpavlin@fpga:/esp32/esp-idf/components/lwip$ mv lwip lwip.old

dpavlin@fpga:/esp32/esp-idf/components/lwip$ git clone https://github.com/martin-ger/esp-lwip lwip
Cloning into 'lwip'...
remote: Enumerating objects: 49642, done.
remote: Total 49642 (delta 0), reused 0 (delta 0), pack-reused 49642
Receiving objects: 100% (49642/49642), 9.70 MiB | 14.52 MiB/s, done.
Resolving deltas: 100% (37485/37485), done.


it does work, but slowly:

dpavlin@nuc:/tmp/esp-lwip$ iperf3 -c 10.0.5.2
Connecting to host 10.0.5.2, port 5201
[  5] local 192.168.3.40 port 52086 connected to 10.0.5.2 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   102 KBytes   833 Kbits/sec    1   28.3 KBytes
[  5]   1.00-2.00   sec  0.00 Bytes  0.00 bits/sec   10   14.1 KBytes
[  5]   2.00-3.00   sec  82.0 KBytes   673 Kbits/sec    2   22.6 KBytes
[  5]   3.00-4.00   sec  0.00 Bytes  0.00 bits/sec    0   28.3 KBytes
[  5]   4.00-5.00   sec  0.00 Bytes  0.00 bits/sec    4   19.8 KBytes
[  5]   5.00-6.00   sec  93.3 KBytes   765 Kbits/sec    4   18.4 KBytes
[  5]   6.00-7.00   sec  0.00 Bytes  0.00 bits/sec    3   5.66 KBytes
[  5]   7.00-8.00   sec  0.00 Bytes  0.00 bits/sec    0   15.6 KBytes
[  5]   8.00-9.00   sec  63.6 KBytes   522 Kbits/sec    0   15.6 KBytes
[  5]   9.00-10.00  sec  0.00 Bytes  0.00 bits/sec    2   5.66 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   341 KBytes   279 Kbits/sec   26             sender
[  5]   0.00-10.18  sec   216 KBytes   174 Kbits/sec                  receiver


enviroment

dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ cat env.sh
export PATH=/nuc/esp32/xtensa-esp32-elf/bin/:$PATH
export ESPIDF=/nuc/esp32/esp-idf/

IP_FORWARD enable in lwip

dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ git diff
diff --git a/ports/esp32/Makefile b/ports/esp32/Makefile
index 756bc8f89..aa03a6370 100644
--- a/ports/esp32/Makefile
+++ b/ports/esp32/Makefile
@@ -494,7 +494,7 @@ ESPIDF_SPI_FLASH_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/spi_flash/*.c))

 ESPIDF_ULP_O = $(patsubst %.c,%.o,$(wildcard $(ESPCOMP)/ulp/*.c))

-$(BUILD)/$(ESPCOMP)/lwip/%.o: CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable
+$(BUILD)/$(ESPCOMP)/lwip/%.o: CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable -DIP_FORWARD=1
 ESPIDF_LWIP_O = $(patsubst %.c,%.o,\
        $(wildcard $(ESPCOMP)/lwip/apps/dhcpserver/*.c) \
        $(wildcard $(ESPCOMP)/lwip/lwip/src/api/*.c) \

build

dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ make V=1

...

xtensa-esp32-elf-size build-GENERIC/application.elf
   text    data     bss     dec     hex filename
1100148  275360   37372 1412880  158f10 build-GENERIC/application.elf
Create build-GENERIC/application.bin
/nuc/esp32/esp-idf//components/esptool_py/esptool/esptool.py --chip esp32 elf2image --flash_mode dio --flash_freq 40m --flash_size 4MB build-GENERIC/application.elf
esptool.py v2.8
Create build-GENERIC/firmware.bin
python3 makeimg.py build-GENERIC/bootloader.bin build-GENERIC/partitions.bin build-GENERIC/application.bin build-GENERIC/firmware.bin
bootloader     21360
partitions      3072
application  1375648
total        1441184

deploy to esp32 using esptool ttyUSB4

dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ make V=1 PORT=/dev/ttyUSB4  deploy
Building with ESP IDF v3
python3 ../../py/makeversionhdr.py build-GENERIC/genhdr/mpversion.h
python3 ../../tools/makemanifest.py -o build-GENERIC/frozen_content.c -v "MPY_DIR=../.." -v "MPY_LIB_DIR=../../../micropython-lib" -v "PORT_DIR=/nuc/upy/micropython/ports/esp32" -v "BOARD_DIR=boards/GENERIC" -b "build-GENERIC" -f"-march=xtensawin" boards/manifest.py
Writing build-GENERIC/firmware.bin to the board
/nuc/esp32/esp-idf//components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB4 --baud 460800 write_flash -z --flash_mode dio --flash_freq 40m 0x1000 build-GENERIC/firmware.bin
esptool.py v2.8
Serial port /dev/ttyUSB4
Connecting........_____....._____....._____...
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 24:0a:c4:31:d6:38
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 1437088 bytes to 921637...
Wrote 1437088 bytes (921637 compressed) at 0x00001000 in 21.5 seconds (effective 535.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

serial

dpavlin@nuc:/nuc/upy/micropython/ports/esp32$ microcom -p /dev/ttyUSB4
connected to /dev/ttyUSB4
Escape character: Ctrl-\
Type the escape character to get to the prompt.

>>>
MPY: soft reboot
AP config:  ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
network config: ('192.168.3.208', '255.255.255.0', '192.168.3.1', '192.168.3.1')
FTP server started on 192.168.4.1:21
FTP server started on 192.168.3.208:21
 esp32 mac: 24:0a:c4:31:d6:38 esp32upy
MicroPython v1.14-dirty on 2021-07-25; ESP32 module with ESP32
Type "help()" for more information.
>>> import machine
>>> machine.reset()
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4972
load:0x40078000,len:10600
load:0x40080400,len:5684
entry 0x400806bc
AP config:  ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
network config: ('192.168.3.208', '255.255.255.0', '192.168.3.1', '192.168.3.1')
FTP server started on 192.168.4.1:21
FTP server started on 192.168.3.208:21
 esp32 mac: 24:0a:c4:31:d6:38 esp32upy
MicroPython v1.14-dirty on 2021-07-25; ESP32 module with ESP32
Type "help()" for more information.

webrepl

ulx3s ppp

permalink
IONCARE GH2127


bigclive https://youtu.be/_zTqZ1edrsU

https://ellestfun.en.alibaba.com/product/60341087076-801987474/IONCARE_wholesale_top_selling_Clenaer_Deodorizer_refrigerator_aroma_diffuser.html

Technical Specifications:

1.Ozone concentration: About 4.0ppm in “High” mode (operates 30 minutes inside a 40L closed container)

2.Effective Range:“High” mode <250L “Low” mode <150L

3.Rating Voltage: DC4.5V

4.Power Supply: 3pcs 1.5V AA-size alkaline batteries

5.Power consumption: 0.5 watts

I measured:

3.7 V * 0.029 A = 0.107 W
4 V * 0.032 A = 0.128W

This is all below 4.5V, but is test for single 18650 cell.

6.Dimensions: H116 x D80 mm

7.Weight: 0.15kg

INCARE GH2128

MONIC FRESHENER & DEODORIZER FOR REFRIGERATORS, CLOSETS BATHROOMS

Instructions

FUNCTIONS AND FEATURES

An innovative device utilizes ionic technology to generate ozone (O₂) & anions to purify the air thoroughly.

1. Neutralize stale and foul odors with fresh air inside refrigerators, closets, bathrooms and cars, etc.

2. Kill all kinds of bacteria to avoid the growth of mildew. 3. Very ideal for use in refrigerator to keep the foods fresh for longer time.

4. Built-in micro CPU intelligently controls the operation cycle & mode by one touch and indicates with the colored LED.

5. Operated by 3 AA batteries. Low voltage indicator reminds you of replacing batteries.

HOW TO OPERATE

1. Remove the battery door on the bottom of the unit, install 3 pieces "AA" 1.5V high-quality alkaline batteries (purchase separately) according to the proper polarity, close with the battery door.

2. Press the "ON/OFF" button once and the power indicator lights up. You may feel a slight breeze from the top grilles, which means the machine on working.

3. Press the "ON/OFF" button again to turn off the unit.

4. Operating mode settings:

1) When the machine is turned on, press the "MODE" button to toggle the operating modes between HIGH and LOW.

2) When the HIGH mode is selected, the power indicator will light up in green and blink.

The machine firstly performs a continuous working for about 30 minutes,
and the power indicator will blink every 2 seconds.

Then the machine will go into a cycle of automatic I-minute's sterilization and deodorization in every 1 hour,
in the other time, the machine will go to sleep and the power indicator will blink every 10 seconds.

3) When the LOW mode is selected, the power indicator will light up in orange and blink.

The machine firstly performs a continuous working for about 20 minutes,
and the power indicator will blink every 2 seconds.

Then the machine will go into a cycle of automatic 40-seconds
sterization and deodorization in every 1 hour
in the other time the machine will go to sleep and the power indicator will blink every 10 seconds.

5. When the power indicator becomes red, this is the butto voltage indicator reminds you of replacing bateries.

SPECIAL ATTENTION

When the machine used in the refrigerator.

1. Make sure to place it into the refrigerator companimens ofer than the freezing compartment.

2. Before taking it from the refrigerator, make sure to tum of is power first.

Due to the lower temperature of the refingerator when the machine comes in contact with the outside air
there will be water condensation on its body and inside, if the machine keeps working,
it maybe leads to the short circuit of the electic parts and corrode the metal parts even the batteries

3. When the indicator becomes red, it's time to change the betteries

Take the machine from the refrigerator, and then wrap it with a clean plastic bag.

Before replacing with the new batteries make sure the temperature of the machine casing raises to room temperature.

CAUTION

1. Take out the batteries if leaving the unit idle for a long time.

2. Do not operate the unit in areas where flammable or combusite products or vapors may be present.

3. Keep the unit away from water.

4. Do not strongly shock the unit to avoid any stack of the inter parts of the unit.

Read and save these instructions

permalink
KiCad
permalink
IMAX B6
RC-Power_BC6_Charger.pdf



MCU

Nuvoton M0517LBN ARM Cortex M0

Nuvoton don’t guarantee the deviation of HIRC(22.1184MHz) for M0517.
M0517 is a special part number of M051 series.

Open source firmware

Flashing

https://groups.google.com/forum/#!msg/cheali-charger/2Rz-dtwZ5Is/zUGr3PzX9bcJ

pinout:

CHARGER -------------DONGLE
ICE_DATA <--------->    SWDIO
ICE_CLK  <--------->    SWCLK
ICE_RST  <--------->    RST (on SWIM header on my programmer)
GND      <--------->    GND
VCC      <--------->     5V

isp_imaxB6_M0517.jpeg

dpavlin@x200:/rest/cvs/cheali-charger$ cat .gitmodules 
[submodule "utils/M0517_flash_tools"]
        path = utils/M0517_flash_tools
        url = https://github.com/sasam/M0517_flash_tools.git


dpavlin@x200:/rest/cvs/cheali-charger/utils/M0517_flash_tools/tcl$ openocd \
 -f /usr/share/openocd/scripts/interface/stlink-v2.cfg \
 -f target_MO517_linux.cfg \
 -f M0517_flash.tcl -f M0517_unlock.tcl

If you get following error:

Error: init mode failed (unable to connect to the target)

Connect RST pin to GND while plugging in ST-Link v2 into computer. This will start M0517 in reset mode (you might see squares in first line of display).

Then, unplug RST pin from GND and connect it to RST and restart openocd. Your IMAX B6 is probably protected, so follow instructions below to unlock it.

Open telnet connection to openocd in other terminal:

dpavlin@x200:/rest/cvs/cheali-charger$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> FlashAprom /rest/cvs/cheali-charger/hex/unstable/cheali-charger-imaxB6-clone_1.99-20150727_nuvoton-M0517.hex

Output from openocd after successful flash:

Open On-Chip Debugger 0.9.0 (2015-05-28-17:08)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control.
  The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
FlashAprom
EraseChip
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v23 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.339130
Info : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : accepting 'telnet' connection on tcp/4444
Image: /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin; Size=34840; Sectors:69; FlashProces:(34840;3584,9;2584,1)
>>>>     Load FlashPgm to SRAM: NU_M051x.bin => 0x20000000
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
276 bytes written at address 0x20000000
downloaded 276 bytes in 0.008215s (32.810 KiB/s)
>>>>     FlashInit:
sp (/32): 0x20001000
pc (/32): 0x20000000
Error: timed out while waiting for target halted

Flash is locked!
Chip erase...
.
.
.
.
.
APROM: Erased!: (0x00000000):0xFFFFFFFF
LDROM: Erased!: (0x00100000):0xFFFFFFFF
Config: Erased!: (0x0030000):0xFFFFFFFF
Image: /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin; Size=34840; Sectors:69; FlashProces:(34840;3584,9;2584,1)
>>>>     Load FlashPgm to SRAM: NU_M051x.bin => 0x20000000
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
276 bytes written at address 0x20000000
downloaded 276 bytes in 0.008211s (32.826 KiB/s)
>>>>     FlashInit:
sp (/32): 0x20001000
pc (/32): 0x20000000
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x41000000 pc: 0x20000048 msp: 0x20001000
r0 (/32): 0x00000000
>>>>     FlashInit stop:
>>>>     EreaseFlash: start
     FLASH sector addr: 0x00000000
     sectors to erease: 0x00000045
r0 (/32): 0x00000000
r1 (/32): 0x00000045
sp (/32): 0x20001000
pc (/32): 0x20000058
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x200000a2 msp: 0x20000fec
r0 (/32): 0x00000000
>>>>    FlashErease: stop
>>>>   FLASH image: /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin to 0x00000000
>> Flash Sector: 0-6 => 0x00000000 (3584)
     SRAM load : tmp/fl.00 => 0x20000120
     FLASH addr: reg r0 0x00000000
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069231s (50.555 KiB/s)
r0 (/32): 0x00000000
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 7-13 => 0x00000e00 (3584)
     SRAM load : tmp/fl.01 => 0x20000120
     FLASH addr: reg r0 0x00000e00
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.068563s (51.048 KiB/s)
r0 (/32): 0x00000E00
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 14-20 => 0x00001c00 (3584)
     SRAM load : tmp/fl.02 => 0x20000120
     FLASH addr: reg r0 0x00001c00
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.068231s (51.296 KiB/s)
r0 (/32): 0x00001C00
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 21-27 => 0x00002a00 (3584)
     SRAM load : tmp/fl.03 => 0x20000120
     FLASH addr: reg r0 0x00002a00
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069227s (50.558 KiB/s)
r0 (/32): 0x00002A00
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 28-34 => 0x00003800 (3584)
     SRAM load : tmp/fl.04 => 0x20000120
     FLASH addr: reg r0 0x00003800
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069238s (50.550 KiB/s)
r0 (/32): 0x00003800
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 35-41 => 0x00004600 (3584)
     SRAM load : tmp/fl.05 => 0x20000120
     FLASH addr: reg r0 0x00004600
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069181s (50.592 KiB/s)
r0 (/32): 0x00004600
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 42-48 => 0x00005400 (3584)
     SRAM load : tmp/fl.06 => 0x20000120
     FLASH addr: reg r0 0x00005400
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069107s (50.646 KiB/s)
r0 (/32): 0x00005400
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 49-55 => 0x00006200 (3584)
     SRAM load : tmp/fl.07 => 0x20000120
     FLASH addr: reg r0 0x00006200
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069117s (50.639 KiB/s)
r0 (/32): 0x00006200
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 56-62 => 0x00007000 (3584)
     SRAM load : tmp/fl.08 => 0x20000120
     FLASH addr: reg r0 0x00007000
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.068143s (51.363 KiB/s)
r0 (/32): 0x00007000
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>> Flash Sector: 63-68 => 0x00007e00 (2584)
     SRAM load : tmp/fl.09 => 0x20000120
     FLASH addr: reg r0 0x00007e00
     SIZE  addr: reg r1 0x00000c00
     BUFFR addr: reg r2 0x20000120
2584 bytes written at address 0x20000120
downloaded 2584 bytes in 0.050122s (50.346 KiB/s)
r0 (/32): 0x00007E00
r1 (/32): 0x00000C00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
>>>>   FLASH image: stop
>>>>    Verify: verify_image /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin 0
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000ff4
verified 34840 bytes in 0.226838s (149.990 KiB/s)
Trajanje init: 0 sec
Trajanje brisi: 2 sec
Trajanje pisi: 2 sec
Trajanje ukupno: 4 sec

Update

dpavlin@x200:/rest/cvs/cheali-charger/utils/M0517_flash_tools/tcl$ openocd -f interface/stlink-v2.cfg -f target_MO517_linux.cfg 
Open On-Chip Debugger 0.9.0 (2015-05-28-17:08)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v23 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.239563
Info : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints


# in other terminal

dpavlin@x200:/rest/cvs/cheali-charger/utils/M0517_flash_tools$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> source M0517_flash.tcl
FlashAprom

> FlashAprom /rest/cvs/cheali-charger/hex/unstable/cheali-charger-imaxB6-clone_1.99-20150727_nuvoton-M0517.hex


Serial port

1 2 3

1 - +5V
2 - TTL TX serial / Vout of LM35
3 - GND

LogView

tsv

grep '$1' cheali.log | sed 's/;/\t/g' | xclip -selection clipboard -i

temperature sensor

cheali-charger version 1.99:

The "Hard way" (any temp probe):
1. connect external temp probe
2. check if there is 5V on temp. connector (between pin 1 (GND) and pin 3)
3. go to: "options"> "calibrate">"temp extern"
(first calibration point: point 0)
  4. set "temp:" to your room temperature (~20�C)
(second calibration point: point 1)
  5. set "calib. p.:" to 1
  6. heat temp. sensor to 60�C
  7. set "temp:" to 60�C (the temperature sensor should be at 60�C at this moment)

The "easy way" (LM35, LM35DZ):
1. connect external temp probe
2. check if there is 5V on temp. connector (between pin 1 (GND) and pin 3)
2. check sensor output voltage, should be: ~0.20V (between pin 1 (GND) and pin 2)
3. go to: "options"> "calibrate">"temp extern"
(first calibration point: point 0)
  4. set "temp:" to your room temperature (~20�C)
(second calibration point: point 1)
  5. set "calib. p.:" to 1
  6. disconnect temperature probe
  7. make a shortcut between pin 1 (GND) and pin 2 on the temperature connector (simulate sensor output voltage = 0V)
  8. set "temp:" to 0�C

backup calibration

memory map

Table 6.13-1 Memory Address Map

Block Name Size Start Address End Address
AP-ROM 8/16/32/64KB 0x0000_0000 0x0000_1FFF (8KB)
      0x0000_3FFF (16KB)
      0x0000_7FFF (32KB)
      0x0000_FFFF (64KB)
Data Flash 4KB 0x0001_F000 0x0001_FFFF
LD-ROM 4KB 0x0010_0000 0x0010_0FFF
User Configuration 1 Words 0x0030_0000 0x0030_0000

backup

> init
> dump_image aprom.bin 0x0 0x10000
dumped 65536 bytes in 0.638086s (100.300 KiB/s)

> dump_image flash_data.bin 0x1f000 0x1000
dumped 4096 bytes in 0.042080s (95.057 KiB/s)

> dump_image ldrom.bin  0x100000 0x1000
SWD DPIDR 0x0bb11477
Failed to read memory at 0x00100000

> dump_image config.bin 0x300000 0x1000
SWD DPIDR 0x0bb11477
Failed to read memory at 0x00300000

create calibration for compile from backup

apply fix for python3 from https://github.com/dpavlin/cheali-charger/tree/python3

dpavlin@nuc:/nuc/cheali-charger/utils/eepromExtractor$ ls -al eeprom.bin
-r--r--r-- 1 dpavlin dpavlin 4096 Jul  5 10:54 eeprom.bin
dpavlin@nuc:/nuc/cheali-charger/utils/eepromExtractor$ ./eeprom.py
magic:  chli
version: 9.3.10
Data(
    magicString = (
        99,
        104,
        108,
        105,
    ),
    architecture = 16385,
    calibrationVersion = 9,
    programDataVersion = 3,
    settingVersion = 10,
    calibration = (
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 50,
                ),
                CalibrationPoint(
                    x = 17148,
                    y = 15976,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 50,
                ),
                CalibrationPoint(
                    x = 17148,
                    y = 15976,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 525,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 5447,
                    y = 1000,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 1919,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 5827,
                    y = 300,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 1,
                    y = 1,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 8000,
                    y = 5940,
                ),
                CalibrationPoint(
                    x = 8642,
                    y = 3479,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 21558,
                    y = 12728,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 52287,
                    y = 1910,
                ),
                CalibrationPoint(
                    x = 45432,
                    y = 0,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25736,
                    y = 3995,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25736,
                    y = 3995,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 51320,
                    y = 7985,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 26220,
                    y = 4002,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 26150,
                    y = 3989,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25169,
                    y = 3916,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25405,
                    y = 3933,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 525,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 5457,
                    y = 1000,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 3013,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 9187,
                    y = 300,
                ),
            ),
        ),
    ),
    calibrationCRC = 53014,
    battery = (
        Battery(
            type = 6,
            capacity = 2000,
            cells = 4,
            Ic = 1000,
            Id = 410,
            Vc_per_cell = 4200,
            Vd_per_cell = 3000,
            minIc = 100,
            minId = 55,
            time = 1000,
            enable_externT = 1,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640>,
        ),
        Battery(
            type = 6,
            capacity = 3000,
            cells = 1,
            Ic = 3000,
            Id = 1000,
            Vc_per_cell = 4200,
            Vd_per_cell = 3000,
            minIc = 300,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0>,
        ),
        Battery(
            type = 1,
            capacity = 2000,
            cells = 1,
            Ic = 2000,
            Id = 490,
            Vc_per_cell = 1800,
            Vd_per_cell = 850,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 1,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740>,
        ),
        Battery(
            type = 2,
            capacity = 3600,
            cells = 2,
            Ic = 3600,
            Id = 1000,
            Vc_per_cell = 1800,
            Vd_per_cell = 1000,
            minIc = 360,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740>,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640>,
        ),
        Battery(
            type = 11,
            capacity = 2000,
            cells = 1,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 3000,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = <v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0>,
        ),
    ),
    programDataCRC = 13555,
    settings = Settings(
        backlight = 70,
        fanOn = 3,
        fanTempOn = 5000,
        dischargeTempOff = 6000,
        audioBeep = 1,
        minIc = 50,
        minId = 50,
        inputVoltageLow = 10000,
        adcNoise = 0,
        UART = 3,
        UARTspeed = 3,
        UARToutput = 1,
        menuType = 1,
    ),
    settingsCRC = 15640,
)
dpavlin@nuc:/nuc/cheali-charger/utils/eepromExtractor$ cp defaultCalibration.cpp ../../src/hardware/nuvoton-M0517/targets/imaxB6-clone/

serial tx and rx on chip pins

  • pin 5 - P3.0 RX
  • pin 7 - P3.1 TX
M051-LQFP-pins.png

M051-LQFP-pins-800.png

openocd upstream support for nuvoton

pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ openocd -f rpi2-swd.cfg -f target/numicro.cfg
Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
swd
cortex_m reset_config sysresetreq

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 1001 kHz
Info : SWD DPIDR 0x0bb11477
Info : NuMicro.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for NuMicro.cpu on 3333
Info : Listening on port 3333 for gdb connections

Program new version

> halt
target halted due to debug-request, current mode: Handler External Interrupt(6)
xPSR: 0x41000016 pc: 0x00000a70 msp: 0x20000f60
> flash write_bank 0 /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210623_nuvoton-M0517.bin
Nuvoton NuMicro: Flash Write ...
wrote 37776 bytes from file /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210623_nuvoton-M0517.bin to flash bank 0 at offset 0x00000000 in 0.906262s (40.706 KiB/s)

> reset
NuMicro.cpu -- clearing lockup after double fault
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0xfffffffe msp: 0x20000eb0
Polling target NuMicro.cpu failed, trying to reexamine
NuMicro.cpu: hardware has 4 breakpoints, 2 watchpoints


This will brick mcu, so don't do it!

openocd 0.10 changes

https://github.com/dpavlin/M0517_flash_tools/tree/fix_openocd_0.10

Update cheali-charger/utils/M0517_flash_tools to branch fix_openocd_0.10

update version

start openocd with raspberry pi configurtaion:

pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ openocd -f target_M0517_rpi.cfg -s /nuc/cheali-charger/utils/M0517_flash_tools/tcl/ -f M0517_flash.tcl -f M0517_unlock.tcl
Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
cortex_m reset_config sysresetreq

FlashAprom
EraseChip
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 1001 kHz
Info : SWD DPIDR 0x0bb11477
Info : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for M0517.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'telnet' connection on tcp/4444

connect and flash latest version

pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
>
> FlashAprom /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210623_nuvoton-M0517.bin

> FlashAprom /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin

target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x00001000 msp: 0x20000ed0
target halted due to breakpoint, current mode: Thread
xPSR: 0x41000000 pc: 0x20000048 msp: 0x20001000
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x200000a2 msp: 0x20000fec
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
> reset

output from openocd:

pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ cat openocd.sh
openocd -s /nuc/cheali-charger/utils/M0517_flash_tools/tcl -f target_M0517_rpi.cfg -f M0517_flash.tcl -f M0517_unlock.tcl
pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ ./openocd.sh
Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
cortex_m reset_config sysresetreq

Flash
EraseChip
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 1001 kHz
Info : SWD DPIDR 0x0bb11477
Info : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for M0517.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'telnet' connection on tcp/4444
Info : dropped 'telnet' connection
Info : accepting 'telnet' connection on tcp/4444
Image: /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin, type: bin; Size=34660; Sectors:68; FlashProces:(34660;3584,9;2404,1)
>>>>     Load FlashPgm to SRAM: NU_M051x.bin => 0x20000000
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x00001144 msp: 0x20000fd8
>>>>     FlashInit:
target halted due to breakpoint, current mode: Thread
xPSR: 0x41000000 pc: 0x20000048 msp: 0x20001000
>>>>     FlashInit stop:
time init: 1 sec
>>>>     EreaseFlash: start
     FLASH sector addr: 0x00000000
     sectors to erease: 0x00000044
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x200000a2 msp: 0x20000fec
>>>>    FlashErease: stop
time erease: 1 sec
>>>>   FLASH image: /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin to 0x00000000
>> Flash Sector: 0-6 => 0x00000000 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 7-13 => 0x00000e00 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 14-20 => 0x00001c00 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 21-27 => 0x00002a00 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 28-34 => 0x00003800 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 35-41 => 0x00004600 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 42-48 => 0x00005400 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 49-55 => 0x00006200 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 56-62 => 0x00007000 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>> Flash Sector: 63-67 => 0x00007e00 (2404)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
>>>>   FLASH image: stop
>>>>    Verify: verify_image /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin 0
time write: 1 sec
time summary: 3 sec
permalink
M8S PRO

Board sticker: M8S PRO R4 S912 3G 32G DDR4 DQ



M8S-PRO.jpg

It doesn't have button soldered, it works like power button in android

Serial port is marked on bottom of board (tx/rx are from cpu perspective)

probably: https://www.geekbuying.com/item/MECOOL-M8S-PRO-S912-KODI-17-0-4K-HDR10-3GB-DDR4-32GB-eMMC-TV-Box-380737.html

Android info

Android 7.1 bootlog from serial: m8s-android-bootlog.txt.gz

U-Boot 2015.01-g9331ff1-dirty (Mar 15 2018 - 16:16:24)

DRAM:  3 GiB
...
        aml_dt soc: gxm platform: q20xrmii variant: 3g
        dtb 0 soc: gxm   plat: q20xrmii   vari: 2g
        dtb 1 soc: gxm   plat: q20xrmii   vari: 3g
      Find match dtb: 1
...
parts: 10
00:      logo	0000000002000000 1
01:  recovery	0000000002000000 1
02:       rsv	0000000000800000 1
03:       tee	0000000000800000 1
04:     crypt	0000000002000000 1
05:      misc	0000000002000000 1
06:      boot	0000000002000000 1
07:    system	0000000080000000 1
08:     cache	0000000020000000 2
09:      data	ffffffffffffffff 4

M8SPRO:/ # uname -a
Linux localhost 3.14.29 #46 SMP PREEMPT Thu Apr 12 19:43:12 CST 2018 armv8l

M8SPRO:/ # cat /proc/cmdline
rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 androidboot.selinux=permissive logo=osd1,loaded,0x3d800000,1080p60hz maxcpus=8 vout=1080p60hz,enable hdmimode=1080p60hz cvbsmode=576cvbs hdmitx= cvbsdrv=0 pq= androidboot.firstboot=0 jtag=apao androidboot.hardware=amlogic mac=D0:76:58:0E:63:A3 androidboot.mac=D0:76:58:0E:63:A3 androidboot.slot_suffix=_a buildvariant=userdebug

M8SPRO:/ # cat /proc/cpuinfo
Processor	: AArch64 Processor rev 4 (aarch64)
processor	: 0
processor	: 1
processor	: 2
processor	: 3
processor	: 4
processor	: 5
processor	: 6
processor	: 7
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 wp half thumb fastmult vfp edsp neon vfpv3 tlsi vfpv4 idiva idivt 
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

Hardware	: Amlogic
Serial		: 220a82006da41365fedf301742726826

M8SPRO:/ # free
		total        used        free      shared     buffers
Mem:       2876604416  2210639872   665964544           0    31326208
-/+ buffers/cache:     2179313664   697290752
Swap:       524283904           0   524283904

M8SPRO:/ # df
ilesystem        1K-blocks    Used Available Use% Mounted on
mpfs               1404592     504   1404088   1% /dev
tmpfs               1404592       0   1404592   0% /mnt
/dev/block/system   2031440  973788   1057652  48% /system
/dev/block/data    26969964 3050864  23919100  12% /data
/dev/block/cache     507848    2860    504988   1% /cache
/dev/block/tee         5115      45      5070   1% /tee
/dev/fuse          26969964 3050864  23919100  12% /mnt/runtime/default/emulated
/dev/fuse          26969964 3050864  23919100  12% /mnt/runtime/read/emulated
/dev/fuse          26969964 3050864  23919100  12% /mnt/runtime/write/emulated


recovery sd

https://www.cnx-software.com/2016/11/19/how-to-create-a-bootable-recovery-sd-card-for-amlogic-tv-boxes/

amlogic info

http://www.linux-meson.com/doku.php

armbian

https://forum.armbian.com/topic/12162-single-armbian-image-for-rk-aml-aw-aarch64-armv8/

dpavlin@nuc:~/Downloads$ xzcat Armbian_20.09_Arm-64_bullseye_current_5.8.5.img.xz | dd iflag=fullblock oflag=direct conv=fsync status=progress bs=1M of=/dev/sdb
dpavlin@nuc:~/Downloads$ sudo mount /dev/sdb1 /mnt/sdb1/
dpavlin@nuc:~/Downloads$ cd /mnt/sdb1/

root@nuc:/mnt/sdb1# cp u-boot-s905x-s912 u-boot.ext

root@nuc:/mnt/sdb1# vi extlinux/extlinux.conf

root@nuc:/mnt/sdb1# grep -v '^#' extlinux/extlinux.conf
LABEL Armbian
LINUX /zImage
INITRD /uInitrd

FDT /dtb/amlogic/meson-gxm-q201.dtb
APPEND root=LABEL=ROOTFS rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0


Note that this board uses meson-gxm-q201.dtb which is internal rmii to make ethernet work!

issue reboot update from android shell to boot from sdcard

ath10k wifi sdio firmware

After booting, you will get error message about missing firmware:

[    7.861827] ath10k_sdio mmc2:0001:1: Failed to find firmware-N.bin (N between 2 and 6) from ath10k/QCA9377/hw1.0: -2
[    7.861838] ath10k_sdio mmc2:0001:1: could not fetch firmware files (-2)

Package firmware-atheros is installed, so it's a bit puzzeling what file is missing, however, if we go to

https://github.com/kvalo/ath10k-firmware.git

we can find sdio firmware at https://github.com/kvalo/ath10k-firmware/tree/master/QCA9377/hw1.0/untested

dpavlin@m8s:~/ath10k-firmware$ git remote -v
origin	https://github.com/kvalo/ath10k-firmware.git (fetch)
origin	https://github.com/kvalo/ath10k-firmware.git (push)

dpavlin@m8s:~/ath10k-firmware$ sudo cp QCA9377/hw1.0/untested/firmware-sdio-5.bin_WLAN.TF.1.1.1-00061-QCATFSWPZ-1 /lib/firmware/ath10k/QCA9377/hw1.0/firmware-sdio-5.bin

After running nmtui and configuring wifi it's available but dies after a while under load.

kernel source

https://github.com/150balbes/Amlogic_s905-kernel

currently, I'm using

dpavlin@m8s:~/linux$ git remote -v
origin	https://github.com/xdarklight/linux (fetch)
origin	https://github.com/xdarklight/linux (push)
dpavlin@m8s:~/linux$ git branch
  master
  meson-mx-integration-5.11-20210124
  meson-mx-integration-5.13-20210503
* meson-mx-integration-5.13-20210523
dpavlin@m8s:~/linux$ cat mason-build.sh
# https://github.com/SLAzurin/armbian-aml-s8xx-kernel-build-steps

# https://github.com/xdarklight/linux

make -j 8 Image dtbs modules && sudo make modules_install dtbs_install install

Installing armbian kernel package doesn't work because /boot partition is vfat and not ext2/4

u-boot source

https://github.com/150balbes/Amlogic_S905-u-boot

balbes150 updates

installing linux image and headers does return error, but works

https://users.armbian.com/balbes150/

gpiod

sudo apt install gpiod

button - gpio 2

root@arm-64:~# gpioget gpiochip0 2 # not pressed
1
root@arm-64:~# gpioget gpiochip0 2 # pressed
0

led - gpio 9

root@arm-64:~# gpioset gpiochip0 9=0 # red

root@arm-64:~# gpioset gpiochip0 9=1 # blue (default)

u-boot

old https://github.com/endlessm/u-boot-meson

I wanted serial console which seems to be missing from armbian build above

wiki seems to suggest repository

https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic

but we are going to use upstream u-boot

dpavlin@m8s:~/u-boot-amlogic$ git remote -v
github	https://github.com/u-boot/u-boot (fetch)

dpavlin@m8s:~/u-boot-amlogic$ libretech-cc_defconfig
dpavlin@m8s:~/u-boot-amlogic$ make -j 8
dpavlin@m8s:~/u-boot-amlogic$ cp u-boot.bin /boot/

abort u-boot with key press and boot new one with

fatload mmc 1 0x1000000 u-boot.bin
go 0x1000000

2020-10 status for amlogic

U-Boot: Porting and Maintaining a Bootloader for a Multimedia SoC Family - Neil Armstrong, BayLibre SAS

https://youtu.be/u0-swEMDFp0

permalink
Lamobo R1
GPIO 2.png

Lamobo/BananaPi R1

http://linux-sunxi.org/Lamobo_R1

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


upgrade to unsupported armbian

This board was last supported on jessie, but it's fully supported in upstream so I did upgrade to latest Armbian as of 2021-05-29.

u-boot

sdcard already had u-boot installed, so I didn't have to touch this in first step. To update
u-boot do following:

root@r1:/home/dpavlin# apt install u-boot-sunxi

root@r1:/home/dpavlin# dd conv=fsync,notrunc if=/usr/lib/u-boot/Lamobo_R1/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8
449+1 records in
449+1 records out
460103 bytes (460 kB, 449 KiB) copied, 0.0449233 s, 10.2 MB/s

distribution

First, I did distribution update to stretch and buster and than added

root@r1:/home/dpavlin# cat /etc/apt/sources.list.d/armbian.list
deb http://beta.armbian.com buster main

kernel

and installed latest sunxi kernel image

apt install linux-image-edge-sunxi

After reboot I was greeted with new kernel

root@r1:/home/dpavlin# uname -a
Linux r1 5.12.7-sunxi #trunk.33 SMP Fri May 28 07:03:36 UTC 2021 armv7l GNU/Linux

configure switch

https://www.kernel.org/doc/html/latest/networking/dsa/b53.html

root@r1:/home/dpavlin# cat /etc/network/interfaces.d/br0
auto br0
iface br0 inet dhcp
#iface br0 inet manual
#	address 192.168.1.1
#	netmask 255.255.255.0
	bridge_ports eth0 wan lan1 lan2 lan3 lan4
	post-up for i in `seq 0 4`; do ip link set up dev lan${i}; done ; ip link set up dev wlan
	bridge_stp off
        bridge_waitport 0
	bridge_fd 0

Ports are (left-to-right, looking from back of board starting at edge towards hdmi connector):

br0: port 3(lan1) entered disabled state
br0: port 4(lan2) entered blocking state
br0: port 4(lan2) entered forwarding state
br0: port 4(lan2) entered disabled state
br0: port 5(lan3) entered blocking state
br0: port 5(lan3) entered forwarding state
br0: port 5(lan3) entered disabled state
br0: port 6(lan4) entered blocking state
br0: port 6(lan4) entered forwarding state
br0: port 6(lan4) entered disabled state
br0: port 2(wan) entered blocking state
br0: port 2(wan) entered forwarding state

switch connects all ports on boot

https://github.com/armbian/build/issues/511#issuecomment-258647387

DSA config on armbian for r1

uart

Connect your UART adapter here:

UART0-RX: J13-P01
UART0-TX: J13-P02
GND: J12-P08

                          GND TX RX
             J12   o  o  o  o  o  o
{SD slot}          o  o  o  o


switch

https://www.mail-archive.com/netdev@vger.kernel.org/msg150526.html

port mirroring

https://www.mail-archive.com/netdev@vger.kernel.org/msg150526.html

# ingress
      tc qdisc  add dev eth1 handle ffff: ingress
      tc filter add dev eth1 parent ffff:           \
               matchall skip_sw                      \
               action mirred egress mirror           \
               dev eth2
# egress
      tc qdisc add dev eth1 handle 1: root prio
      tc filter add dev eth1 parent 1:               \
               matchall skip_sw                       \
               action mirred egress mirror            \
               dev eth2

usb otg

http://git.rot13.org/?p=usb-otg;a=summary

usbproxy

make sure that there are no other usb modules loaded (libcomposite or g_*)

mitm usb otg machine

dpavlin@r1:~/USBProxy$ git remote -v
origin  https://github.com/dominicgs/USBProxy (fetch)
origin  https://github.com/dominicgs/USBProxy (push)

dpavlin@r1:~/USBProxy/src/build$ sudo usb-mitm -l -v 058f -p 6387 -P PacketFilter_MassStorage
Loading plugins from /usr/local/lib/USBProxy/
vendorId=058f
productId=6387
cleaning up /tmp
removing 1
Made directory /tmp/gadget-SOOBVj for gadget
UnblockPassword=
Printing Config data
        Strings: 4
                DeviceProxy: DeviceProxy_LibUSB
                HostProxy: HostProxy_GadgetFS
                productId: 6387
                vendorId: 058f
        Vectors: 1
                Plugins:
                        PacketFilter_StreamLog
                        PacketFilter_MassStorage
Pointer: 1
                PacketFilter_StreamLog::file: 0xb6d779f0
Device: 12 01 00 02 00 00 00 40 8f 05 87 63 00 01 01 02 03 01
  Manufacturer: JetFlash
  Product:      Mass Storage Device
  Serial:       GUYOBHDU
        *Config(1): 09 02 20 00 01 01 00 80 32
                Interface(0):
                        *Alt(0): 09 04 00 00 02 08 06 50 00
                                EP(01): 07 05 01 02 00 02 00
                                EP(82): 07 05 82 02 00 02 00
HS Qualifier: 0a 06 00 02 00 00 00 40 01 00
         Config(1): 09 07 20 00 01 01 00 80 32
                Interface(0):
                        *Alt(0): 09 04 00 00 02 08 06 50 00
                                EP(01): 07 05 01 02 40 00 00
                                EP(82): 07 05 82 02 40 00 00
searching in [/tmp/gadget-SOOBVj]
Starting injector thread (14796) for [Injector].
Injector In FD[1/1]: 3
Starting setup writer thread (14799) for EP00.
Starting setup reader thread (14797) for EP00.
[80 06 00 03 00 00 ff 00]
[80 06 00 03 00 00 04 00]: 04 03 09 04
[80 06 02 03 09 04 ff 00]
[80 06 02 03 09 04 28 00]:
        28 03 4d 00 61 00 73 00 73 00 20 00 53 00 74 00 6f 00 72 00 61 00 67 00 65 00 20 00 44 00 65 00
        76 00 69 00 63 00 65 00
[80 06 01 03 09 04 ff 00]
[80 06 01 03 09 04 12 00]: 12 03 4a 00 65 00 74 00 46 00 6c 00 61 00 73 00 68 00
[80 06 03 03 09 04 ff 00]
[80 06 03 03 09 04 12 00]: 12 03 47 00 55 00 59 00 4f 00 42 00 48 00 44 00 55 00
[00 09 01 00 00 00 00 00]
Opened EP01
Opened EP82
Starting writer thread (14802) for EP01.
Starting reader thread (14803) for EP82.
Starting writer thread (14804) for EP82.
Starting reader thread (14801) for EP01.
[a1 fe 00 00 00 00 01 00]
[a1 fe 00 00 00 00 00 00]
01[31]: 55 53 42 43 01 00 00 00 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00
CBW: (12), tag: 01 00 00 00

[80 06 03 03 09 04 ff 00]
[80 06 03 03 09 04 12 00]: 12 03 47 00 55 00 59 00 4f 00 42 00 48 00 44 00 55 00
[00 09 01 00 00 00 00 00]


original target device

dpavlin@nuc:~$ journalctl -t kernel -f
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: new high-speed USB device number 45 using xhci_hcd
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: New USB device found, idVendor=058f, idProduct=6387
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: Product: Mass Storage Device
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: Manufacturer: JetFlash
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: SerialNumber: GUYOBHDU
Sep 01 11:10:04 nuc kernel: usb-storage 2-4.4.2:1.0: USB Mass Storage device detected
Sep 01 11:10:04 nuc kernel: scsi host5: usb-storage 2-4.4.2:1.0

# BUT!

dpavlin@nuc:~$ sudo fdisk -l /dev/sdb
fdisk: cannot open /dev/sdb: No medium found


WiringPi

dpavlin@r1:~/BPI-WiringPi2$ git remote -v
lanefu  https://github.com/lanefu/WiringOtherPi (fetch)
lanefu  https://github.com/lanefu/WiringOtherPi (push)
origin  https://github.com/BPI-SINOVOIP/BPI-WiringPi2 (fetch)
origin  https://github.com/BPI-SINOVOIP/BPI-WiringPi2 (push)

dpavlin@r1:~/BPI-WiringPi2$ gpio readall
 +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |    SDA.0 |   IN | 0 |  3 || 4  |   |      | 5V       |     |     |
 |  11 |   9 |    SCL.0 |   IN | 0 |  5 || 6  |   |      | 0v       |     |     |
 |   6 |   7 |   GPIO.7 |   IN | 0 |  7 || 8  | 0 | IN   | TxD3     | 15  | 13  |
 |     |     |       0v |      |   |  9 || 10 | 0 | IN   | RxD3     | 16  | 14  |
 |   1 |   0 |     RxD2 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO.1   | 1   | 110 |
 |   0 |   2 |     TxD2 |   IN | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |     CTS2 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO.4   | 4   | 68  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | IN   | GPIO.5   | 5   | 71  |
 |  64 |  12 |     MOSI |   IN | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |     MISO |   IN | 0 | 21 || 22 | 0 | IN   | RTS2     | 6   | 2   |
 |  66 |  14 |     SCLK |   IN | 0 | 23 || 24 | 0 | IN   | CE0      | 10  | 67  |
 |     |     |       0v |      |   | 25 || 26 | 0 | IN   | GPIO.11  | 11  | 21  |
 |  19 |  30 |    SDA.1 |   IN | 0 | 27 || 28 | 0 | IN   | SCL.1    | 31  | 18  |
 |   7 |  21 |  GPIO.21 |   IN | 0 | 29 || 30 |   |      | 0v       |     |     |
 |   8 |  22 |  GPIO.22 |   IN | 0 | 31 || 32 | 0 | IN   | RTS1     | 26  | 200 |
 |   9 |  23 |  GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v       |     |     |
 |  10 |  24 |  GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | CTS1     | 27  | 201 |
 |  20 |  25 |  GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | TxD1     | 28  | 198 |
 |     |     |       0v |      |   | 39 || 40 | 0 | IN   | RxD1     | 29  | 199 |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+



TMP75

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


userland

dpavlin@r1:~$ cc tmp.c -o tmp -lm
dpavlin@r1:~$ sudo ./tmp /dev/i2c-1 0x49
21.5


kernel hwmomn lm75 driver

root@r1:~# echo lm75 0x49 > /sys/bus/i2c/devices/i2c-1/new_device 

root@r1:~# dmesg | tail -2
[68352.599623] lm75 1-0049: hwmon1: sensor 'lm75'
[68352.599719] i2c i2c-1: new_device: Instantiated device lm75 at 0x49

root@r1:/sys/bus/i2c/devices/i2c-1# sensors
sun4i_ts-isa-0000
Adapter: ISA adapter
SoC temperature:  +44.4°C  

lm75-i2c-1-49
Adapter: mv64xxx_i2c adapter
temp1:        +22.0°C  (high = +80.0°C, hyst = +75.0°C)

network performance

kernel 3.4

root@r1:~# uname -a
Linux r1 3.4.113-sun7i #23 SMP PREEMPT Wed Jun 14 23:57:45 CEST 2017 armv7l GNU/Linux

root@r1:~# iperf3 --reverse --client nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[  4] local 192.168.3.238 port 58203 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   107 MBytes   897 Mbits/sec                  
[  4]   1.00-2.00   sec   110 MBytes   923 Mbits/sec                  
[  4]   2.00-3.00   sec   111 MBytes   935 Mbits/sec                  
[  4]   3.00-4.00   sec   107 MBytes   894 Mbits/sec                  
[  4]   4.00-5.00   sec   111 MBytes   927 Mbits/sec                  
[  4]   5.00-6.00   sec   110 MBytes   922 Mbits/sec                  
[  4]   6.00-7.00   sec   111 MBytes   928 Mbits/sec                  
[  4]   7.00-8.00   sec   111 MBytes   935 Mbits/sec                  
[  4]   8.00-9.00   sec   111 MBytes   928 Mbits/sec                  
[  4]   9.00-10.00  sec   111 MBytes   931 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.08 GBytes   924 Mbits/sec  147             sender
[  4]   0.00-10.00  sec  1.07 GBytes   922 Mbits/sec                  receiver

iperf Done.

root@r1:~# iperf3 --client nuc
Connecting to host nuc, port 5201
[  4] local 192.168.3.238 port 58205 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  51.3 MBytes   428 Mbits/sec    0    239 KBytes       
[  4]   1.00-2.01   sec  52.5 MBytes   436 Mbits/sec    0    240 KBytes       
[  4]   2.01-3.02   sec  52.5 MBytes   436 Mbits/sec    0    245 KBytes       
[  4]   3.02-4.01   sec  50.0 MBytes   424 Mbits/sec    0    246 KBytes       
[  4]   4.01-5.02   sec  51.2 MBytes   429 Mbits/sec    0    247 KBytes       
[  4]   5.02-6.02   sec  52.5 MBytes   439 Mbits/sec    0    250 KBytes       
[  4]   6.02-7.03   sec  51.2 MBytes   427 Mbits/sec    0    253 KBytes       
[  4]   7.03-8.00   sec  48.8 MBytes   418 Mbits/sec    0    256 KBytes       
[  4]   8.00-9.02   sec  52.5 MBytes   432 Mbits/sec    0    256 KBytes       
[  4]   9.02-10.01  sec  51.2 MBytes   435 Mbits/sec    0    256 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.01  sec   514 MBytes   431 Mbits/sec    0             sender
[  4]   0.00-10.01  sec   514 MBytes   431 Mbits/sec                  receiver

kernel 4.13

root@r1:~# uname -a
Linux r1 4.13.10-sunxi #57 SMP Mon Oct 30 00:08:27 CET 2017 armv7l GNU/Linux

root@r1:~# iperf3 --client nuc
Connecting to host nuc, port 5201
[  4] local 192.168.3.238 port 59520 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  67.9 MBytes   567 Mbits/sec    0    765 KBytes       
[  4]   1.00-2.01   sec  82.1 MBytes   687 Mbits/sec    0    840 KBytes       
[  4]   2.01-3.01   sec  65.7 MBytes   547 Mbits/sec    0   1.13 MBytes       
[  4]   3.01-4.02   sec  80.0 MBytes   669 Mbits/sec    0   1.13 MBytes       
[  4]   4.02-5.00   sec  76.2 MBytes   648 Mbits/sec    0   1.24 MBytes       
[  4]   5.00-6.00   sec  81.2 MBytes   681 Mbits/sec    0   1.24 MBytes       
[  4]   6.00-7.06   sec  82.5 MBytes   656 Mbits/sec    0   1.33 MBytes       
[  4]   7.06-8.00   sec  80.0 MBytes   712 Mbits/sec    0   1.33 MBytes       
[  4]   8.00-9.00   sec  78.8 MBytes   659 Mbits/sec    0   1.61 MBytes       
[  4]   9.00-10.00  sec  83.8 MBytes   702 Mbits/sec    0   2.08 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec   778 MBytes   653 Mbits/sec    0             sender
[  4]   0.00-10.00  sec   775 MBytes   650 Mbits/sec                  receiver

iperf Done.

root@r1:~# iperf3 --reverse --client nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[  4] local 192.168.3.238 port 59524 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  98.0 MBytes   822 Mbits/sec                  
[  4]   1.00-2.00   sec   112 MBytes   933 Mbits/sec                  
[  4]   2.00-3.00   sec   107 MBytes   904 Mbits/sec                  
[  4]   3.00-4.00   sec   107 MBytes   898 Mbits/sec                  
[  4]   4.00-5.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   5.00-6.00   sec   108 MBytes   903 Mbits/sec                  
[  4]   6.00-7.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   7.00-8.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   8.00-9.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   9.00-10.00  sec   107 MBytes   899 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.05 GBytes   900 Mbits/sec   69             sender
[  4]   0.00-10.00  sec  1.05 GBytes   898 Mbits/sec                  receiver



kernel 5.12.7

dpavlin@r1:~$ uname -a
Linux r1 5.12.7-sunxi #trunk.33 SMP Fri May 28 07:03:36 UTC 2021 armv7l GNU/Linux

dpavlin@r1:~$ iperf3 -c nuc
Connecting to host nuc, port 5201
[  5] local 192.168.3.238 port 50136 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.02   sec  41.9 MBytes   346 Mbits/sec    0    239 KBytes
[  5]   1.02-2.02   sec  53.8 MBytes   448 Mbits/sec    0    266 KBytes
[  5]   2.02-3.00   sec  42.5 MBytes   363 Mbits/sec    0    266 KBytes
[  5]   3.00-4.02   sec  53.8 MBytes   445 Mbits/sec    0    277 KBytes
[  5]   4.02-5.01   sec  53.8 MBytes   456 Mbits/sec    0    325 KBytes
[  5]   5.01-6.02   sec  48.1 MBytes   400 Mbits/sec    0    386 KBytes
[  5]   6.02-7.03   sec  48.8 MBytes   405 Mbits/sec    0    386 KBytes
[  5]   7.03-8.00   sec  46.2 MBytes   397 Mbits/sec    0    386 KBytes
[  5]   8.00-9.02   sec  53.8 MBytes   443 Mbits/sec    0    393 KBytes
[  5]   9.02-10.00  sec  51.2 MBytes   438 Mbits/sec    0    393 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   494 MBytes   414 Mbits/sec    0             sender
[  5]   0.00-10.01  sec   494 MBytes   414 Mbits/sec                  receiver

iperf Done.
dpavlin@r1:~$ iperf3 -R -c nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[  5] local 192.168.3.238 port 50140 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.01   sec  66.9 MBytes   559 Mbits/sec
[  5]   1.01-2.00   sec  69.8 MBytes   588 Mbits/sec
[  5]   2.00-3.00   sec  66.8 MBytes   560 Mbits/sec
[  5]   3.00-4.00   sec  67.6 MBytes   567 Mbits/sec
[  5]   4.00-5.00   sec  67.6 MBytes   568 Mbits/sec
[  5]   5.00-6.00   sec  65.3 MBytes   548 Mbits/sec
[  5]   6.00-7.00   sec  66.5 MBytes   558 Mbits/sec
[  5]   7.00-8.00   sec  65.4 MBytes   549 Mbits/sec
[  5]   8.00-9.00   sec  66.7 MBytes   560 Mbits/sec
[  5]   9.00-10.00  sec  65.2 MBytes   547 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.01  sec   672 MBytes   563 Mbits/sec   57             sender
[  5]   0.00-10.00  sec   668 MBytes   560 Mbits/sec                  receiver

iperf Done.
permalink
Turris Omnia


documentation

reset modes

https://www.turris.cz/doc/en/howto/omnia_factory_reset

 Available reset modes:

    1 LED: Standard (re)boot
    2 LEDs: Rollback to latest snapshot
    3 LEDs: Rollback to factory reset
    4 LEDs: Re-flash router from flash drive
    5 LEDs or more: Boot to rescue shell

vlan

GPIO pinout

omnia-pin-header.png

PWM same on all pins

Debian

root@turris:/mnt/tmp# wget http://aule.elfove.cz/~brill/omnia-debian/omnia-medkit-20170330.tar.gz

# boot into rescue mode

root@(none):~# mount /dev/mmcblk0p1 /target/

root@(none):~# btrfs subvolume create /target/@debian


watchdog will timeout, but you will eventually have subvolume visible from u-boot (which is not case if you just create subvolume from Turris OS

root@turris:/# btrfs sub create @debian
Create subvolume './@debian'

root@turris:/# cd /@debian
root@turris:/@debian# tar xf /mnt/tmp/omnia-medkit-20170330.tar.gz 
root@turris:/@debian# btrfs fi df .
System, single: total=32.00MiB, used=4.00KiB
Data+Metadata, single: total=3.68GiB, used=2.25GiB
GlobalReserve, single: total=48.00MiB, used=0.00B

root@turris:/@debian# vi etc/network/interfaces
auto br0
iface br0 inet static
        bridge_ports wlan0 eth0 eth2
        address 192.168.3.254
        netmask 255.255.255.0
        gateway 192.168.3.1
root@turris:~# echo b > /proc/sysrq-trigger
[54760.278340] sysrq: SysRq : Resetting
[54760.282039] CPU1: stopping
   
U-Boot SPL 2015.10-rc2 (Aug 18 2016 - 20:43:35)
High speed PHY - Version: 2.0
SERDES0 card detect: NONE
   
Initialize Turris board topology
Detected Device ID 6820
board SerDes lanes topology details:
 | Lane #  | Speed |  Type       |
 --------------------------------
 |   0    |  5   |  PCIe0       |
 |   1    |  5   |  USB3 HOST0  |
 |   2    |  5   |  PCIe1       |
 |   3    |  5   |  USB3 HOST1  |
 |   4    |  5   |  PCIe2       |
 |   5    |  0   |  SGMII2      |
 --------------------------------
poll_op_execute: TIMEOUT
PCIe, Idx 0: detected no link
PCIe, Idx 1: detected no link
PCIe, Idx 2: detected no link
High speed PHY - Ended Successfully
DDR3 Training Sequence - Ver TIP-1.29.0
Memory config in EEPROM: 0x01
DDR3 Training Sequence - Switching XBAR Window to FastPath Window
DDR3 Training Sequence - Ended Successfully

   
U-Boot 2015.10-rc2 (Aug 18 2016 - 20:43:35 +0200), Build: jenkins-omnia-master-23
   
SoC:   MV88F6820-A0
       Watchdog enabled
I2C:   ready
SPI:   ready
DRAM:  1 GiB (ECC not enabled)
Enabling Armada 385 watchdog.
Disabling MCU startup watchdog.
Regdomain set to **
MMC:   mv_sdh: 0
SF: Detected S25FL164K with page size 256 Bytes, erase size 64 KiB, total 8 MiB
*** Warning - bad CRC, using default environment
   
Model: Marvell Armada 385 GP
Board: Turris Omnia SN: 0000000B0000B8E5
Regdomain set to **
SCSI:  MVEBU SATA INIT
SATA link 0 timeout.
SATA link 1 timeout.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
Net:   neta2
Hit any key to stop autoboot:  0
=> 

=> setenv debbootargs earlyprintk console=ttyS0,115200 rootfstype=btrfs rootwait root=/dev/mmcblk0p1 rootflags=subvol=@debian,commit=5 rw
=> setenv debboot 'setenv bootargs "$debbootargs cfg80211.freg=$regdomain"; btrload mmc 0 0x01000000 boot/vmlinuz @debian; btrload mmc 0 0x02000000 boot/dtb @debian; btrload mmc 0 0x03000000 boot/initrd.img @debian; bootz 0x01000000 0x03000000:$filesize 0x02000000'
=> saveenv
Saving Environment to SPI Flash...
SF: Detected S25FL164K with page size 256 Bytes, erase size 64 KiB, total 8 MiB
Erasing SPI flash...Writing to SPI flash...done

=> setenv defbootcmd "$bootcmd"
=> setenv debbootcmd 'i2c dev 1; i2c read 0x2a 0x9 1 0x00FFFFF0; setexpr.b rescue *0x00FFFFF0; if test $rescue -ge 2; then echo BOOT RESCUE; run rescueboot; else if test $rescue -ge 1; then echo BOOT eMMC TurrisOS FS; run mmcboot; else echo BOOT eMMC Debian FS; run debboot; fi; fi'
=> setenv bootcmd "$debbootcmd"
=> saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done

u-boot problem

Kernel image @ 0x1000000 [ 0x000000 - 0x332588 ]
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid

https://docs.turris.cz/hw/omnia/serial-boot/#u-boot

update u-boot

=> dhcp
neta2:1 is connected to neta2.  Reconnecting to neta2
neta2 Waiting for PHY auto negotiation to complete............ done
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
*** Unhandled DHCP Option in OFFER/ACK: 208
*** Unhandled DHCP Option in OFFER/ACK: 208
DHCP client bound to address 192.168.4.113 (5583 ms)
*** Warning: no boot file name; using 'C0A80471.img'
Using neta2 device
TFTP from server 192.168.4.1; our IP address is 192.168.4.113
Filename 'C0A80471.img'.
Load address: 0x800000
Loading: *
TFTP error: 'file /var/tftp/C0A80471.img not found' (1)
Not retrying...
=> tftpboot 0x1000000 uboot-turris-omnia-spl.kwb
Using neta2 device
TFTP from server 192.168.4.1; our IP address is 192.168.4.113
Filename 'uboot-turris-omnia-spl.kwb'.
Load address: 0x1000000
Loading: #####################################
         2.6 MiB/s
done
Bytes transferred = 534240 (826e0 hex)
=> sf probe
SF: Detected S25FL164K with page size 256 Bytes, erase size 64 KiB, total 8 MiB
=> sf update 0x1000000 0 $filesize
device 0 offset 0x0, size 0x826e0
534240 bytes written, 0 bytes skipped in 10.563s, speed 51765 B/s

fix default variables and boot from mmc (I did 4 leds rescue before)

env default -a
saveenv
run mmcboot

rescue image

root@x230:/var/tftp# wget https://repo.turris.cz/hbs/omnia/packages/turrispackages/rescue-image_3.4-1_arm_cortex-a9_vfpv3-d16.ipk
root@x230:/var/tftp# mkdir tmp
root@x230:/var/tftp# cd tmp/
root@x230:/var/tftp/tmp# tar xvf ../rescue-image_3.4-1_arm_cortex-a9_vfpv3-d16.ipk
./debian-binary
./data.tar.gz
./control.tar.gz
root@x230:/var/tftp/tmp# tar xvf data.tar.gz
./
./usr/
./usr/share/
./usr/share/rescue-image/
./usr/share/rescue-image/image.fit
./usr/share/rescue-image/image.fit.lzma
root@x230:/var/tftp/tmp# cp usr/share/rescue-image/image.fit.lzma ../

now flash new rescue

=> tftpboot ${kernel_addr_r} image.fit.lzma
Using neta2 device
TFTP from server 192.168.4.1; our IP address is 192.168.4.113
Filename 'image.fit.lzma'.
Load address: 0x800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###########################
         2.4 MiB/s
done
Bytes transferred = 6115919 (5d524f hex)

=> sf probe
SF: Detected S25FL164K with page size 256 Bytes, erase size 64 KiB, total 8 MiB
=> sf update ${kernel_addr_r} 0x00100000 ${filesize}
device 0 offset 0x5d524f, size 0x22adb1
SPI flash failed in erase step

update from shell

opkg install u-boot-omnia
opkg install rescue-image

root@turris:~# nor-update -d
Verifying /dev/mtd0 against /usr/share/omnia/uboot-devel ...
a107291f748c9b3d9d96dd718e3e471a - /dev/mtd0
15b3b8e4100351677e85b983ef659921 - /usr/share/omnia/uboot-devel
Failed
Unlocking /dev/mtd0 ...
Erasing /dev/mtd0 ...

Writing from /usr/share/omnia/uboot-devel to /dev/mtd0 ...
Verifying /dev/mtd1 against /usr/share/rescue-image/image.fit.lzma ...
1ea91207d0fbd4479bb4c8b4a3957371 - /dev/mtd1
82194bc8fc95193cc3f3491a047b0c88 - /usr/share/rescue-image/image.fit.lzma
Failed
Unlocking /dev/mtd1 ...
Erasing /dev/mtd1 ...

Writing from /usr/share/rescue-image/image.fit.lzma to /dev/mtd1 ...

This will make route unbootable :-(

Reflash router via usb https://docs.turris.cz/hw/omnia/rescue-modes/#re-flash-router

permalink
innbox v80

pictures

position of plastic clips to unclip after removing screws

innobox-v80-case-clips-20210522_192312.jpg

top of board

innobox-v80-top-20210522_192339.jpg

bottom of board

innobox-v80-back-20210522_192256.jpg

software version

Hardware version: 1.0
Active image: 2
Firmware image 1: 1.0.839
Firmware image 2: 1.1.966
Checksum of image 1: 34e4b3948d00a869d961283510a7eb08
Checksum of image 2: a6e08754c908c237d1539cb143611697
Firmware bootloader: 1.9
CRC of bootloader: a6e08754c908c237d1539cb143611697

serial

4 pins, pin 1 marked with triangle

1: TX
2: RX
3: GND
4: 3V3 (?)

serial output

(partial)

BGA IC
Xtal:1
DDR3 init.
DRAMC init done.
Calculate size.
DRAM size=128MB
Set new TRFC.

7512DRAMC V1.2.2 (0)


EN751221 at Fri Apr 16 11:48:25 CST 2021 version 1.9 free bootbase

Memory size 128MB

Set SPI Clock to 50 Mhz
spi_nand_probe: mfr_id=0xc8, dev_id=0x21
Using Flash ECC.
Detected SPI NAND Flash : _SPI_NAND_DEVICE_ID_F50L1G, Flash Size=0x8000000
bmt pool size: 81
BMT & BBT Init Success


>>>> [get_env_info] hw_id:InnboxV80_PW2
>>>> [set_gpio_define] g_hw_id:InnboxV80_PW2
Reset button GPIO is: 0
Press any key in 3 secs to enter boot command mode.
............................................................

Invalid Power GPIO, just return and don't turn on Power LED

NAND FLASH

>>>> CTC: boot_flag_addr: 53e0fff; flag: 1 version_addr:53e1000 version:1.9<FF><FF><FF><FF>

==> boot flag = 1
Decompress to 80002000 free_mem_ptr=80E00000 free_mem_ptr_end=807B0000
from slave
Uncompressing [LZMA] ...  done.
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.18.21 (iskratel@2d7d74f016e9) (gcc version 4.6.3 (Buildroot 2015.08.1) ) #3 SMP Fri Apr 16 11:32:58 CST 2021
ISPRAM0: PA=00770000,Size=00010000,enabled
Config7: 0x80080500
memsize:120MB
EcoNet EN751221 SOC prom init
bootconsole [early0] enabled
CPU0 revision is: 00019558 (MIPS 34Kc)
Determined physical RAM map:
 memory: 077fe000 @ 00002000 (usable)
Wasting 64 bytes for tracking 2 unused pages
Zone ranges:
  Normal   [mem 0x00002000-0x077fffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x00002000-0x077fffff]
Initmem setup node 0 [mem 0x00002000-0x077fffff]
Detected 1 available secondary CPU(s)
Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
PERCPU: Embedded 9 pages/cpu @810f3000 s5664 r8192 d23008 u36864
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 30478
Kernel command line:  es=1
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Writing ErrCtl register=0002e01a
Readback ErrCtl register=0002e01a
nmi base is 81124200
Memory: 110280K/122872K available (7640K kernel code, 1290K rwdata, 1624K rodata, 304K init, 551K bss, 12592K reserved)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:64

tc3162_time_init: Init bus timeout and watchdog
plat_set_irq_affinity: cpu 0
plat_set_irq_affinity: cpu 0 vpe_id 0
plat_set_irq_affinity: irq_vpe0 1 irq_vpe1 0, irq = 10
plat_set_irq_affinity: irq num 10
plat_set_irq_affinity: cpu 0
plat_set_irq_affinity: cpu 0 vpe_id 0
plat_set_irq_affinity: irq_vpe0 1 irq_vpe1 0, irq = 33
plat_set_irq_affinity: irq num 33
CPU frequency 900.00 MHz
plat_time_init: Entered, mips_timer_ack ptr is [80006dd4]
 Using 200.000 MHz high precision timer.
r4k_clockevent_init: setup_irq OK, irq is [31]
console [ttyS0] enabled
console [ttyS0] enabled
bootconsole [early0] disabled
bootconsole [early0] disabled
Calibrating delay loop... 597.60 BogoMIPS (lpj=2988032)
pid_max: default: 32768 minimum: 301

boot loader

bldr> ?

?                                   Print out help messages.
help                                Print out help messages.
go                                  Booting the linux kernel.
decomp                              Decompress kernel image to ram.
memrl <addr>                        Read a word from addr.
memwl <addr> <value>                Write a word to addr.
dump <addr> <len>                   Dump memory content.
jump <addr>                         Jump to addr.
flash <dst> <src> <len> <oob>       Write to flash from src to dst(oob: write nand oob if 1).
imginfo                             Show images info.
spinand_rwtest                      Flash Test
bdstore <flash dst> <bin src>       Do backdoor config store
bdshow                              Show backdoor config
bdswitch[1|0]                       Enable or disable backdoor function
ddrcalswitch[1|0]                   Enable or disable ddr calibration funciton
drambistswitch[0|1|2]               disable or enable, and quick or normal test
xmdm <addr> <len>                   Xmodem receive to addr.
miir <phyaddr> <reg>                Read ethernet phy reg.
miiw <phyaddr> <reg> <value>        Write ethernet phy reg.
cpufreq <freq num> / <m> <n>        Set CPU Freq <156~450>(freq has to be multiple of 6)
ipaddr <ip addr>                    Change modem's IP.
httpd                               Start Web Server
mtd
bldr> bdshow
back door config is not support NAND Flash
permalink
Weblog Navigation
Loading...
Weblog Archives
  • Loading...