Quick jump:  What's new

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

https://docs.ai-thinker.com/en/esp32c3

ESP32-C3_Kit
3528

ESP-C3-32S



chip_id

dpavlin@nuc:/nuc/esp32/esp-idf/examples$ /nuc/esp32/esptool/esptool.py --port /dev/ttyUSB4 chip_id
esptool.py v3.2-dev
Serial port /dev/ttyUSB4
Connecting....
Detecting chip type... ESP32-C3
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:b6:b4:94
Uploading stub...
Running stub...
Stub running...
Warning: ESP32-C3 has no Chip ID. Reading MAC instead.
MAC: 7c:df:a1:b6:b4:94
Hard resetting via RTS pin...

flash_id

dpavlin@nuc:/nuc/esp32/esp-idf/examples$ /nuc/esp32/esptool/esptool.py --port /dev/ttyUSB4 flash_id
esptool.py v3.2-dev
Serial port /dev/ttyUSB4
Connecting....
Detecting chip type... ESP32-C3
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:b6:b4:94
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 6015
Detected flash size: 2MB
Hard resetting via RTS pin...

module info

https://docs.ai-thinker.com/_media/esp32/docs/esp-c3-32s-kit-v1.0_specification.pdf

Wiring of onboard lights

IO5 is connected to RGB blue lamp beads; IO3 is connected to
RGB red lamp beads; IO4 is connected to RGB green lamp
beads; IO19 is connected to cool color lamp beads; IO18 is
connected to warm color lamp beads;(high level is valid)

permalink
CH341A mini flash programmer


ch341a_miniprogrammer.jpg

This is 5V device without modification! It works for me(tm) but you have been warned

http://www.eevblog.com/forum/repair/ch341a-serial-memory-programmer-power-supply-fix/

Just lift pin 28 and put some tape under it to prevent any short circuit. Then solder one wire from this pin to pin 2 of AMS1117 and also to C4. The side of the C4 to connect is the one connected to CH341A pin 9.

CHM341A-3V3-fix.jpg

jumper on pins

1-2 SPI flash programmer mode
2-3 TTL serial mode

supported out-of-box by flashrom, probably better option, but anyway:

https://github.com/setarcos/ch341prog

dpavlin@nuc:/nuc/ch341a$ git clone https://github.com/setarcos/ch341prog
Cloning into 'ch341prog'...
remote: Counting objects: 104, done.
remote: Total 104 (delta 0), reused 0 (delta 0), pack-reused 104
Receiving objects: 100% (104/104), 34.79 KiB | 0 bytes/s, done.
Resolving deltas: 100% (61/61), done.
Checking connectivity... done.
dpavlin@nuc:/nuc/ch341a$ cd ch341prog/
dpavlin@nuc:/nuc/ch341a/ch341prog$ make
gcc -std=gnu99 -Wall ch341a.c main.c -o ch341prog  -lusb-1.0
dpavlin@nuc:/nuc/ch341a/ch341prog$ ./ch341prog 

Usage:
 -h, --help             display this message
 -i, --info             read the chip ID info
 -e, --erase            erase the entire chip
 -l, --length <bytes>   manually set length
 -w, --write <filename> write chip with data from filename
 -r, --read <filename>  read chip and save data to filename
 -t, --turbo            increase the i2c bus speed (-tt to use much faster speed)
 -d, --double           double the spi bus speed

I2C in userspace

https://sourceforge.net/projects/ch341eepromtool/

dpavlin@nuc:/nuc/ch341a/ch341eepromtool_0.5$ gcc -o ch341eeprom ch341eeprom.c ch341funcs.c -lusb-1.0
dpavlin@nuc:/nuc/ch341a/ch341eepromtool_0.5$ 
dpavlin@nuc:/nuc/ch341a/ch341eepromtool_0.5$ ./ch341eeprom 
ch341eeprom - an i2c EEPROM programming tool for the WCH CH341a IC
Version 0.5 copyright (c) 2011  asbokid <ballymunboy@gmail.com>

This program comes with asbolutely no warranty; This is free software,
and you are welcome to redistribute it under certain conditions:
GNU GPL v3 License: http://www.gnu.org/licenses/gpl.html

Usage:
 -h, --help             display this text
 -v, --verbose          verbose output
 -d, --debug            debug output
 -s, --size             size of EEPROM {24c32|24c64}
 -e, --erase            erase EEPROM (fill with 0xff)
 -w, --write <filename> write EEPROM with image from filename
 -r, --read  <filename> read EEPROM and save image to filename

Example:  ch341eeprom -v -s 24c64 -w bootrom.bin

flashrom SPI

Not needed anymore, included in mainline flashrom

git clone https://github.com/urjaman/flashrom/
git checkout -b origin/ch341a origin/ch341a

dpavlin@nuc:/nuc/flashrom$ sudo apt-get install pciutils-dev



linux kernel spi module

dpavlin@nuc:/nuc$ git clone https://github.com/gschorcht/spi-ch341-usb.git
Cloning into 'spi-ch341-usb'...
remote: Counting objects: 63, done.
remote: Total 63 (delta 0), reused 0 (delta 0), pack-reused 63
Unpacking objects: 100% (63/63), done.
dpavlin@nuc:/nuc$ cd spi-ch341-usb
dpavlin@nuc:/nuc/spi-ch341-usb$ make
make -C /usr/src/linux-headers-4.14.0-3-amd64/ M=/nuc/spi-ch341-usb  modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.0-3-amd64'
  CC [M]  /nuc/spi-ch341-usb/spi-ch341-usb.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /nuc/spi-ch341-usb/spi-ch341-usb.mod.o
  LD [M]  /nuc/spi-ch341-usb/spi-ch341-usb.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.14.0-3-amd64'
dpavlin@nuc:/nuc/spi-ch341-usb$ 
dpavlin@nuc:/nuc/spi-ch341-usb$ sudo make install
[sudo] password for dpavlin: 

dpavlin@nuc:/nuc/spi-ch341-usb$ sudo modprobe spi-ch341-usb

[525021.048281] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output cs0 SPI slave with cs=0
[525021.048285] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output cs1 SPI slave with cs=1
[525021.048287] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output cs2 SPI slave with cs=2
[525021.048290] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio4 gpio=0 irq=0 (hwirq)
[525021.048292] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio5 gpio=1 irq=1 
[525021.048296] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI master connected to SPI bus 0
[525021.048426] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI device /dev/spidev0.0 created
[525021.048516] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI device /dev/spidev0.1 created
[525021.048596] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI device /dev/spidev0.2 created
[525021.049147] spi-ch341-usb 2-2.1.4:1.0: ch341_usb_probe: connected
[525021.049194] usbcore: registered new interface driver spi-ch341-usb



linux kernel i2c module

root@nuc:/nuc# git clone https://github.com/gschorcht/i2c-ch341-usb.git
Cloning into 'i2c-ch341-usb'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
root@nuc:/nuc# cd i2c-ch341-usb
root@nuc:/nuc/i2c-ch341-usb# make
make -C /usr/src/linux-headers-4.14.0-3-amd64/ M=/nuc/i2c-ch341-usb  modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.0-3-amd64'
  CC [M]  /nuc/i2c-ch341-usb/i2c-ch341-usb.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /nuc/i2c-ch341-usb/i2c-ch341-usb.mod.o
  LD [M]  /nuc/i2c-ch341-usb/i2c-ch341-usb.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.14.0-3-amd64'
root@nuc:/nuc/i2c-ch341-usb# 
root@nuc:/nuc/i2c-ch341-usb# sudo make install

root@nuc:/nuc/i2c-ch341-usb# modprobe i2c-ch341-usb

[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio0 gpio=0 irq=0 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio1 gpio=1 irq=1 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio2 gpio=2 irq=2 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio3 gpio=3 irq=3 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio4 gpio=4 irq=4 (hwirq)
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio5 gpio=5 irq=5 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio6 gpio=6 irq=6 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio7 gpio=7 irq=7 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_i2c_probe: created i2c device /dev/i2c-8
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_i2c_set_speed: Change i2c bus speed to 100 kbps
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_usb_probe: connected
[Wed Feb  7 16:37:00 2018] usbcore: registered new interface driver i2c-ch341-usb






schematics and info

I added soic 8 pinout over zif socket, because position of pin 1 is not obvious (or clearly marked anywhere on top). I suggest that you fix that with silver sharpy.

ch341a_miniprogrammer_schematic.png

alternative schematics

https://github.com/Upcycle-Electronics/CH341A-Pro

ch341Apro_schematicV01.pdf
permalink
DPS5005


OpenDPS

pinout

SWO-pinout.jpg

upgrade to opensource firmware

https://github.com/kanflo/opendps.git

dpavlin@nuc:/nuc$ git clone --recursive https://github.com/kanflo/opendps.git
dpavlin@nuc:/nuc$ cd opendps/
dpavlin@nuc:/nuc/opendps$ make -C libopencm3
dpavlin@nuc:/nuc/opendps$ make -C opendps


connecting rst pin to unpowered st-link stops dps5005 from booting

https://johan.kanflo.com/upgrading-your-dps5005/

openocd

pi@pihdmi:~ $ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f1x.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
WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : STLINK V2J28S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.273018
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections

backup few states

from another terminal

pi@pihdmi:/nuc/opendps $ ./ocd-client.py all | tee 5V-off.txt

# exit openocd, turn output on

pi@pihdmi:/nuc/opendps $ ./ocd-client.py all | tee 5V-on.txt


erase

pi@pihdmi:/nuc/opendps $ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset halt
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080010a4 msp: 0x20001ff0
> flash erase_address unlock 0x08000000 0x10000
device id = 0x10016420
flash size = 64kbytes
erased address 0x08000000 (length 65536) in 0.145284s (440.517 KiB/s)

flash

pi@pihdmi:/nuc/opendps/opendps $ make flash
  FLASH   opendps_DPS5005.srec
(echo "halt; program /nuc/opendps/opendps/opendps_DPS5005.srec verify reset" | nc -4 localhost 4444 2>/dev/null) || \
        openocd -f interface/stlink-v2.cfg \
        -f target/stm32f1x.cfg \
        -c "program opendps_DPS5005.srec verify reset exit" \
        2>/dev/null
��������Open On-Chip Debugger
> halt; program /nuc/opendps/opendps/opendps_DPS5005.srec verify reset
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x08000bb8 msp: 0x20001fb8
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080010a4 msp: 0x20001ff0
** Programming Started **
device id = 0x10016420
flash size = 64kbytes
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **


pi@pihdmi:/nuc/opendps/dpsboot $ make flash
  FLASH   dpsboot.srec
(echo "halt; program /nuc/opendps/dpsboot/dpsboot.srec verify reset" | nc -4 localhost 4444 2>/dev/null) || \
        openocd -f interface/stlink-v2.cfg \
        -f target/stm32f1x.cfg \
        -c "program dpsboot.srec verify reset exit" \
        2>/dev/null
��������Open On-Chip Debugger
> halt; program /nuc/opendps/dpsboot/dpsboot.srec verify reset
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x08000bb8 msp: 0x20001fb8
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080010a4 msp: 0x20001ff0
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **



client software

pi@pihdmi:/nuc/opendps $ pip3 install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting crc16==0.1.1 (from -r requirements.txt (line 1))
  Downloading https://www.piwheels.org/simple/crc16/crc16-0.1.1-cp37-cp37m-linux_armv7l.whl
Requirement already satisfied: pyserial==3.4 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 2)) (3.4)
Installing collected packages: crc16
Successfully installed crc16-0.1.1
pi@pihdmi:/nuc/opendps $ cd dpsctl/

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --ping
Error: timeout talking to device /dev/ttyUSB2.

# swap rx/tx pins

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --ping
Got pong from device

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --query
Func       : cv (on)
  voltage  : 5000
  current  : 1000
V_in       : 10.77 V
V_out      : 5.03 V
I_out      : 0.001 A
pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 -o off

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --query
Func       : cv (off)
  voltage  : 5000
  current  : 1000
V_in       : 10.78 V
V_out      : 1.73 V
I_out      : 0.001 A

pi@pihdmi:/nuc/opendps/dpsctl $ python3 ./dpsctl.py --device /dev/ttyUSB2 --query
Func       : cv (off)
  voltage  : 5000
  current  : 1000
V_in       : 10.78 V
V_out      : 0.01 V
I_out      : 0.000 A


serial upgrade

pi@pihdmi:/nuc/opendps/dpsctl $ python3 dpsctl.py --device /dev/ttyUSB2 -U ../opendps/opendps_DPS5005.bin
Download progress: 2% Error: timeout talking to device /dev/ttyUSB2.

SEL on power-on to stay in bootloader

# it bricked my board first time I tried it

esp8266

I had trouble finding toolchain which works with it, I ended up using https://github.com/pfalcon/esp-open-sdk

dpavlin@nuc:/nuc/esp8266/esp-open-sdk$ git remote -v
origin  https://github.com/pfalcon/esp-open-sdk.git (fetch)
origin  https://github.com/pfalcon/esp-open-sdk.git (push)

I also needed to replace esptool, since this machine requires python3 version of it

ln -s /nuc/esp32/esptool/esptool.py /nuc/esp8266/esp-open-sdk/xtensa-lx106-elf/bin/esptool.py

wifi config

dpavlin@nuc:/nuc/opendps$ ls -al esp8266-proxy/esp-open-rtos/include/private_ssid_config.h
-rw-r--r-- 1 dpavlin dpavlin 60 Aug  4 10:21 esp8266-proxy/esp-open-rtos/include/private_ssid_config.h
dpavlin@nuc:/nuc/opendps$ vi esp8266-proxy/esp-open-rtos/include/private_ssid_config.h

build

dpavlin@nuc:/nuc/opendps$ cd esp8266-proxy/
dpavlin@nuc:/nuc/opendps/esp8266-proxy$ cat env.sh
export EOR_ROOT=`pwd`/esp-open-rtos
export PATH=/nuc/esp8266/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
dpavlin@nuc:/nuc/opendps/esp8266-proxy$ . env.sh

dpavlin@nuc:/nuc/opendps/esp8266-proxy$ make

Merged 1 ELF section

flash

dpavlin@nuc:/nuc/opendps/esp8266-proxy$ make flash
esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 16m -fm qio -ff 40m \
        0x0 esp-open-rtos/bootloader/firmware_prebuilt/rboot.bin 0x1000 esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/dpsproxy.bin
WARNING: Flash size arguments in megabits like '16m' are deprecated.
Please use the equivalent size '2MB'.
Megabit arguments may be removed in a future release.
esptool.py v3.2-dev
Serial port /dev/ttyUSB0


pi@pihdmi:/nuc/opendps/esp8266-proxy $ /nuc/esp32/esptool/esptool.py --port /dev/ttyUSB3 write_flash 0x0 esp-open-rtos/bootloader/firmware_prebuilt/rboot.bin 0x1000 esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/dpsproxy.bin
esptool.py v3.2-dev
Serial port /dev/ttyUSB3
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:c2:6b:19
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00000fff...
Flash will be erased from 0x00001000 to 0x00001fff...
Flash will be erased from 0x00002000 to 0x00043fff...
Compressed 3104 bytes to 2169...
Wrote 3104 bytes (2169 compressed) at 0x00000000 in 0.3 seconds (effective 79.1 kbit/s)...
Hash of data verified.
Compressed 2048 bytes to 23...
Wrote 2048 bytes (23 compressed) at 0x00001000 in 0.1 seconds (effective 132.3 kbit/s)...
Hash of data verified.
Compressed 268660 bytes to 195361...
Wrote 268660 bytes (195361 compressed) at 0x00002000 in 18.0 seconds (effective 119.6 kbit/s)...
Hash of data verified.

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


test

reset board and verify that it's connecting to wifi

pi@rpi4:/nuc/opendps/dpsctl $ microcom -p /dev/ttyUSB0 -s 9600
connected to /dev/ttyUSB0
Escape character: Ctrl-\
Type the escape character to get to the prompt.
2dnټ�bdbz�$�`dl��x$2�+`b:`:r�pd�zt{�[�8)1J������: sta(4c:11:ae:0d:1f:ab)
add if0
scandone
add 0
aid 16
cnt

connected with dreamhouse, channel 10
dhcp client start...
ip:192.168.3.111,mask:255.255.255.0,gw:192.168.3.1

now test client

pi@rpi4:~ $ /nuc/opendps/dpsctl/dpsctl.py -S
192.168.3.111
^C

pi@rpi4:~ $ export DPSIF=192.168.3.111

pi@rpi4:~ $ /nuc/opendps/dpsctl/dpsctl.py -q
Func       : cv (off)
  voltage  : 5000
  current  : 1000
V_in       : 9.71 V
V_out      : 0.00 V
I_out      : 0.000 A

powering esp8266

3.3v voltage is available at jtag pins, but it can't supply enough current to run esp8266

There is 5v pin from buck converter on top-left pin of 2x4 pins on left side of board (when looking from back side of module)

5v gnd
 o o
 o o
 o o
 o o

IMG_20210809_170438-800.jpg

power drain from input voltage is roughly doubled when powering esp8266 from 5v rail

input voltage no esp8266 with esp8266
7.68 v 55 mA 110 mA
9v 46 mA 97 mA
permalink
Blue Pill
The-Generic-STM32F103-Pinout-Diagram.pdf



stm32f103 board

arduino boot loader

triple usb serial

pill_serial

Function Pin and Port
USART3 TX PB10
USART3 RX PB11
USART2 TX PA2
USART2 RX PA3
USART1 TX PA9
USART1 RX PA10

USART TX pin RX pin special speed sensor linux
3 PB10 PB11   9600 MH-Z19B /dev/ttyACM1
2 PA2 PA3   9600    
1 PA9 PA10 BOOT=0 9600    

dpavlin@nuc:/nuc/stm32/pill_serial$ cat flash.sh
sudo ../stlink/build/Release/st-flash write src/pill_serial.bin 0x08000000

lower serial speed to 9600 so we can use slow sensors on it: serial-speed.diff

bluepill-serial-monster

https://github.com/r2axz/bluepill-serial-monster

openocd with raspberry pi

http://git.rot13.org/?p=openocd-rpi2-stm32;a=blob;f=openocd-rpi.txt

clones

https://github.com/thanks4opensource/buck50/issues/2

https://github.com/keirf/Greaseweazle/wiki/STM32-Fakes

dpavlin@nuc:/nuc/stm32/Greaseweazle$ wget https://github.com/keirf/Greaseweazle/releases/download/v0.22/Greaseweazle-v0.22.zip

dpavlin@nuc:/nuc/stm32/Greaseweazle$ unzip Greaseweazle-v0.22.zip Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex
Archive:  Greaseweazle-v0.22.zip
  inflating: Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex

write it to flash using openocd

> flash write_image erase /nuc/stm32/Greaseweazle/Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex 0 ihex
auto erase enabled
wrote 5120 bytes from file /nuc/stm32/Greaseweazle/Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex in 0.299529s (16.693 KiB/s)

serial output is on the programming interface at pins A9/TX and A10/RX: Not via the USB port!

pi@pihdmi:/nuc/stm32/buck50 $ microcom -p /dev/ttyUSB1
connected to /dev/ttyUSB1
Escape character: Ctrl-\
Type the escape character to get to the prompt.

** Blinky
** Blinky Test **
** Keir Fraser <keir.xen@gmail.com>
** https://github.com/keirf/Greaseweazle
Serial = ff48:0670:8967:5655:4740:6706
Flash Size  = 128kB
Device ID = 0x0000
Revision  = 0x0000
Testing I2C1... OK
Testing I2C2... OK
Testing SPI1... OK
Testing SPI2... OK
Testing TIM1... OK
Testing TIM2... OK
Testing TIM3... OK
Testing TIM4... OK
DMA Test #1... OK
DMA Test #2... OK
DMA Test #3... OK
DMA Test #4... OK
Testing 64kB Flash... OK
Enable TIM4 IRQ... .OK
Testing 20kB SRAM (endless loop)................................................................

After flashing this test, you will not be able to address blue pill using openocd.

To work-around this problem, I switched boot0 jumper, used stm32loader (after pressing reset button) to load alternative binary.

permalink
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
Weblog Navigation
Loading...
Weblog Archives
  • Loading...