jueves, 3 de septiembre de 2020

flashing espruino+ninebot/eucWatch to a P8 smartwatch

Flashing espruino+eucWatch (formerly ninebot-one)

[updated]

P8 with ninebot/enaon+espruino

Intro: 
Espruino: is javascript engine ported to nrf52 and P8 (fanoush)
Ninebot-one (nb): is a watch software that besides time, has some additional functions, especially the one that originally gave name to the software, a "page" that displays info from a unicycle mobility device.
eucWatch: latest version and new name for the Ninebot-one software
ATCwatch: another software for P8 based in Arduino (see other articles of this blog)




Steps:

1) Flash bootloader
1.1) if you have Dafit/stock ROM
or 
1.2B) if you have ATCwatch installed on the P8  
2) Daflasher step
3) Espruino step (PC and Chrome)
Configuring/coding nb espruino:
Using nb/ninebot UI
  

From a browser download following apps from github
  • DaFitBootloader23Hacked.bin (A custom Bootloader using the preInstalled SoftDevice5.0.1)

If you start from p8 default status/Dafit stock then you have to install before the first 2 files.

 1) Flash bootloader

1.1) if you have Dafit/stock ROM 

 You must install before:
    DaFitBootloader23Hacked.bin
    FitbootloaderDFU2 zip 
(common steps with flashing ATCwatch)
 
On Daflasher
Select: P8 
(wait until button "Select File" is enabled)
Select File : DaFitBootloader23Hacked.bin
P8 screen [green screen, progress bar and end in 3 color squares]

Select: ATCdfu
Click button "Do DFU Update"
Selectfile: FitbootloaderDFU2 zip [check Use Nordic Bootloader]

(it can take a long time, fail several times during the process and recontinue from last %. But at the end it should complete flashing the file, speed is slow i.e 2,20kB/s)

  P8 screen    [red square and ATCnetz.de]

 

1.2) if you have ATCwatch installed on the P8

From p8 menu, Click "Bootloader"
  P8 screen    [red square and ATCnetz.de]

 

2) Daflasher step

At BLE devices list

Select: ATCdfu

Click button "Do DFU Update"
   [Checked box: Nordic bootloader]
   [Unchecked box: Toggle Bluetooth]
Select DFU file:  espruino_2v0x.xx_p8_SDK11_SD20.zip  

3) Espruino step (PC and Chrome)

(only tested on Windows) 

    Bluetooth has to be on
   "Connection Icon", "Web Bluetooth", P8 xxxx
   on left side terminal type:
             "require("Storage").eraseAll()"
 
  •  how to Flash /Upload "init" file   

Having  right side windows clear (empty of code)

Drag an drop "init" file to left side (

Click on Send to espruino arrow down icon, choose Upload destination, "Storage" , choose name ".bootrst"

 Click on ".bootrst"

 

  •   (optional) Edit "handler" file before upload 
Depending on P8 model, touch and accelerator controller can change
 
for example for a P8a/TFK5 set
      const touchtype="716" and acctype="BMA421"
 whereas a P8b can be a touchtype="716" or "816S" and acctype="SC7A20"
  • Upload files
[enter in DEV mode]
  type on the left side:     reset() ,   [press enter while holding the button on the p8]
 
>reset()

=undefined
Welcome!
*** DevMode ***
Short press the side button

to restart in WorkingMode

  •    Click on Storage/HD icon (Access files in device's storage),   "Upload a file":  handler, main, settings, calc,...
  (handler, main, settings, minimum files required for basic/testing)
  (euc file is not required, only for ninebot unicycle owners).


  • Verify/execute

Click on Storage/HD icon (Access files in device's storage), verify existence of files and .bootrst

short tap on the button, and it will boot to working mode

 On left side terminal, execute command "reset()" or "E.reboot()"  (last one reset the hardware and loose the time)

DEV mode: (required for future files upload)

Do a reset() while holding the p8 button

from Settings-info- long press in restart button

 

Configuring/coding nb espruino:

During file upload, time is set on espruino. However, depending on timezone  value for an attribute, the displayed time can be wrong.
 
file: init/.bootrst  (Now .bootcde)
E.setTimeZone(2);
// 3=default
// Spain 1 winter time  2 summer time 
 
file:handler
const touchtype="716"; //716 for P8a/TFK | 816|816s for P8b
 
(for models and hardware check a previous post)  
 
Upgrading espruino
Daflasher
Chose: p8
Click "Start bootloader"
p8 screen [redsquare]
DFU 
 
Upgrading n-b (ninebot) version or many files

Erase and start from scratch
 
require("Storage").eraseAll()
connect
 
require("Storage").compact()  [???]
init to .bootrst




 
 

Using nb/ninebot UI

reset() .The normal reset, command or from p8 screen, "INF" (settings-info) menu, long hold on reboot
E.reboot() , command or from p8  holding the button for~15 secs, it will kick the watchdog 
 
TOR=Torch
AL=Alarms (for timer, hold press and will set current time+10min)
CALC= Calculator
BRI=Bright
ACC=Accelerator/step counter
HID=control over bluetooth keyb/media
CLI=enable nordic serial (required by espruino IDE webIDE)
ATC=enable to sync with d6Notification android app (time, receive commands...)


Set time. 
from web IDE: upload an empty code to RAM
from d6: re/enable notification
BLE command: AT+DT=202008251300 (2020-Aug25th13:00)


type of events:
button,
long press button,
long press touch screen
Slide left/right/left touch screen
Slide up/down/up touch screen


No hay comentarios: