On Linux (and command line on Windows) follow directions on https://www.espruino.com/ESP8266_Flashing.
To do it with a graphical user-interface get the NodeMCU Flasher at https://github.com/nodemcu/nodemcu-flasher, there's a Win32/Release and a Win64/Release. I'm assuming you're using the 4MB version, it is as cheap as the 1MB version.
The ESP8266 firmware is available at http://www.espruino.com/binaries/ with the current version at http://www.espruino.com/binaries/espruino_1v92_esp8266_4mb/. Download the files
boot_v1.6.bin, espruino_esp8266_user1.bin, esp_init_data_default.bin and blank.bin (espruino_esp8266_user2.bin is not needed).
Start NodeMCU Flasher, switch to the Config tab and load the files setting these addresses:
boot_v1.6.bin: 0x00000
espruino_esp8266_user1.bin: 0x01000
esp_init_data_default.bin: 0x3FC000
blank.bin: 0x3FE000
Adjust the settings at the "Advanced" tab like this:
Baudrate: 115200
Flash size: 4MByte
Flash speed: 40MHz
SPI mode: DIO
If you didn't connect the ESP8266 to the computers USB port it is time to do this now. Then switch to the "Operation" tab, select the COM port and click "Flash (F)" to flash the module.
You can see the flash progress. If you look at the "Log" tab there should be plenty of lines saying "Note:Program flash success.", a few "Note:Set base address success." and the last line will say "Note:Serial port disconnected.".
That's it, now you can use the Espruino Web IDE to connect (Communications: Baud Rate: 115200) or any other program to connect to the serial port. To test type "1+1", press Enter and the response will be "=2" (actually you can type in any valid JavaScript code to test, as such "let x=1+1;" returns the same response).
If it doesn't work just try to flash it again, some boards don't flash properly - especially if your PC can't deliver enough power at the USB port. If you can't flash it successfully after a few times then try using an other USB port, another PC or an external power source for flashing.
Here's a short program to make the build-in LED on the ESP-12 blink fast. You an just paste it to the left side of the editor.
var on = true;
var LED = NodeMCU.D4; //pin 4 of NodeMCU (pin2 of ESP8266)
var onOffTime = 50; //milliseconds
setInterval(function() {
on = !on;
LED.write(on);
}, onOffTime);
Saturday, April 29, 2017
Friday, March 17, 2017
Compiling ffmpeg with hardware encoder h264
Here's what I did to have hardware acceleration for the h264 encoder of the Allwiner H3 chip on my Orange Pi Lite. I takes about an hour to compile the code, overall maybe two hours.
Step 1 - download stuff
apt-get install libmp3lame-dev
apt-get install libpulse-dev
apt-get install libv4l-dev
apt-get install libx264-dev
apt-get autoremove
git clone https://github.com/stulluk/FFmpeg-Cedrus
Step 2 - a small fix
Edit the file ./FFmpeg-Cedrus/libavcodec/cabac_functions.h by adding a few lines:
#ifndef UNCHECKED_BITSTREAM_READER
#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
#endif
Source for this modification:
http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/2014-October/081768.html
Step 3 - complile and install
cd FFmpeg-Cedrus
./configure --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2
make clean
make -Wno-deprecated-declarations -Wno-unused-function -Wno-unused-variable -Wno-address -Wno-empty-body
make install
You can check the temperature and frequency during install, for me it stayed at 58..60°C and 1.2 GHz.
cat /sys/devices/virtual/thermal/thermal_zone0/temp /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
Step 4 - test and configure
Here we go
/usr/bin/ffmpeg -encoders | grep h264
You should have a line saying "V..... cedrus264 Cedrus H.264 Encoder (codec h264)".
Step 5 - discover that cedrus264 will accept only special formats
Priceless
Step 1 - download stuff
apt-get install libmp3lame-dev
apt-get install libpulse-dev
apt-get install libv4l-dev
apt-get install libx264-dev
apt-get autoremove
git clone https://github.com/stulluk/FFmpeg-Cedrus
Step 2 - a small fix
Edit the file ./FFmpeg-Cedrus/libavcodec/cabac_functions.h by adding a few lines:
#ifndef UNCHECKED_BITSTREAM_READER
#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
#endif
Source for this modification:
http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/2014-October/081768.html
Step 3 - complile and install
cd FFmpeg-Cedrus
./configure --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2
make clean
make -Wno-deprecated-declarations -Wno-unused-function -Wno-unused-variable -Wno-address -Wno-empty-body
make install
You can check the temperature and frequency during install, for me it stayed at 58..60°C and 1.2 GHz.
cat /sys/devices/virtual/thermal/thermal_zone0/temp /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
Step 4 - test and configure
Here we go
/usr/bin/ffmpeg -encoders | grep h264
You should have a line saying "V..... cedrus264 Cedrus H.264 Encoder (codec h264)".
Step 5 - discover that cedrus264 will accept only special formats
Priceless
Monday, February 13, 2017
Controlling 16 rc servos with the Adafruit 16-Channel 12-bit PWM/Servo Driver PCA9685 with Orange Pi Lite over I2C
I'll use the command line to do all things, not going into details of the PCA9685 (see my previous post for details), and I'm assuming you have an Orange Pi Lite with armbian installed.
The cabling is shown for reference:
| Orange Pi Lite - I2C bus 0 |
First thing to get are the i2c-tools:
apt-get install i2c-tools
Then you can probe the i2c bus and should see the device already:
i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e fThe address 0x40 is the chip address, while 0x70 is an additional address of the chip that appears on the bus, it will vanish after modifying the MODE0 register. For details see the datasheet.
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --
Initializing the PCA9685 chip and setting PWM values:
#With auto-increment it is possible to write all three channels at once, starting at address 0x06:
#init
#
i2cset -y 0 0x40 0x00 16 #sleep
i2cset -y 0 0x40 0xFE 121 #50 Hz
i2cset -y 0 0x40 0x00 32 #auto-increment
sleep 1s
i2cset -y 0 0x40 0x00 `expr 32 + 128` #auto-increment and restart
#
#write values to the first three channels
#
#auto-increment
i2cset -y 0 0x40 0x06 0 0 255 0 i
#auto-increment
i2cset -y 0 0x40 0x0A 0 0 255 2 i
#four commands
i2cset -y 0 0x40 0x0E 0
i2cset -y 0 0x40 0x0F 0
i2cset -y 0 0x40 0x10 255
i2cset -y 0 0x40 0x11 1
i2cset -y 0 0x40 0x06 0 0 255 0 0 0 255 2 0 0 255 1 iThat's it.
Actual numbers for my servos:
i2cset -y 0 0x40 0x06 0 0 240 1 i #max
i2cset -y 0 0x40 0x06 0 0 71 1 i #center
i2cset -y 0 0x40 0x06 0 0 132 0 i #min
Subscribe to:
Posts (Atom)