August 18, 2016, 7:43 am
I’ve been working with the esp8266 spi driver by MetalPhreak located here. One of the issues I’ve found is that duplex transfers (where you want to both send and receive at the same time) don’t work correctly. If you attempt to call spi_transaction specifying 8 dout_bits and 8 din_bits 16 clocks will be sent (IIRC a receive followed by a transmit).
The misunderstanding is likely down to the fact that the esp8266 has very little documentation. And the SPI registers aren’t documented at all. However the Arduino guys seem to have figured it out and it works correctly in the Arduino IDE board pack for the esp8266.
The trick is to set the SPI_USER register just so. There are 3 bits which control the direction of transfer SPI_USR_MOSI, SPI_USR_MISO and SPI_DOUTDIN (bits 27,28 and 0). In order to send and receive you need to set SPI_DOUTDIN and SPI_USR_MOSI but NOT SPI_USR_MISO. At least that’s what’s worked for me.
I made the following modification to spi_transaction to fix this. Change the line reading:
if(din_bits) {SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_MISO);}
to
if((din_bits) && (dout_bits)) {
SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_DOUTDIN);
} else {
if(din_bits) {SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_MISO);}
}
I’ll probably submit a pull request once I’ve made all the changes required for my project. But in this meantime this should work.
August 10, 2016, 4:29 pm
Put the following in .git/pre-commit (make sure it’s executable):
git diff --cached --name-only > commits_list
And the following in .git/post-commit:
#!/bin/bash
if [ -f commits_list ]
then
currentdate=`date`
cat commits_list | while read F
do
echo $PWD/$F
filebase=`basename $F`
sed -i -e 's/\$Date[^$]*\$/\$Date '"$currentdate"'\$/' $PWD/$F
sed -i -e 's/\$Filename[^$]*\$/\$Filename '"$filebase"'\$/' $PWD/$F
git add $PWD/$F
done
rm commits_list
git commit --amend --no-verify -C HEAD
fi
Still not extensively tested…
August 6, 2016, 1:06 pm
I’ll update this post with further notes, but these files can be used to recover the SDG2024x with complete corrupt flash (such as you might happen if you put an SD in the internal SD card slot and rebooted the device). The MLO is the u-boot spl, but you need to removed the first 520 bytes. If you upload this over xmodem, followed by u-boot.img over ymodem (do not reboot between uploads) over the internal serial console (exposed on a header) you should get a u-boot prompt. From here you can upload the other images (kernel, rootfs etc.). Alternatively on an SD card and insert it into the SDF2024x and run mmc-all (IIRC) this should also flash all the remaining image files.
uEnv.txt
u-boot.img
ro_uImage
rootfs
MLO
August 5, 2016, 10:52 am
I used the following to backup my flash:
mmc rescan
nand read 0x82000000 0x03680000 0x03200000
fatwrite mmc0 0:1 0x82000000 firmware0 0x03200000
nand read 0x82000000 0x06880000 0x03200000
fatwrite mmc0 0:1 0x82000000 firmware1 0x03200000
nand read 0x82000000 0x09a80000 0x06580000
fatwrite mmc0 0:1 0x82000000 datafs 0x06580000
nand read 0x82000000 0x03080000 0x00600000
fatwrite mmc0 0:1 0x82000000 kernel 0x00600000
nand read 0x82000000 0x00580000 0x02b00000
fatwrite mmc0 0:1 0x82000000 rootfs 0x02b00000
nand read 0x82000000 0x00280000 0x00300000
fatwrite mmc0 0:1 0x82000000 Manufacturedata 0x02b00000
nand read 0x82000000 0x00260000 0x00020000
fatwrite mmc0 0:1 0x82000000 u-boot-env 0x00020000
nand read 0x82000000 0x00080000 0x001e0000
fatwrite mmc0 0:1 0x82000000 u-boot 0x001e0000
nand read 0x82000000 0x00060000 0x00020000
fatwrite mmc0 0:1 0x82000000 SPL.backup3 0x00020000
nand read 0x82000000 0x00040000 0x00020000
fatwrite mmc0 0:1 0x82000000 SPL.backup2 0x00020000
nand read 0x82000000 0x00020000 0x00020000
fatwrite mmc0 0:1 0x82000000 SPL.backup1 0x00020000
nand read 0x82000000 0x00000000 0x00020000
fatwrite mmc0 0:1 0x82000000 SPL 0x00020000
Images below:
u-boot-en
u-boo
SPL
SPL
SPL
SP
rootf
kerne
firmware
firmware