PDA

View Full Version : Commands on EEPROM


dirkvl
2014-01-13, 22:14
So, I found this in my mailbox today:

http://i43.tinypic.com/2qu3rjc.jpg

An AT24C02 EEPROM with a wopping 256 bytes of data :p

Since EEPROMS are very very easy to program (http://www.cutedigi.com/arduino-shields/i2c-eeprom-for-arduino-256kbit.html), this is a very quick way to make your custom OH instantly very awesome!

But, since I am an extreme hardware guy (and a little low on software knowlegde), what to put on them??

Howto:
-download a picture and set it as ambiance?
-download and install a program?
-change settings?
-start a daemon?

Also, they are dirt-cheap.

dirkvl
2014-01-13, 22:27
Also, GITHUB has this page (https://github.com/KonstaT/sailfishos_kernel_jolla_msm8930/blob/master/drivers/mfd/toh.c)

struct toh_eeprom_entry toh_eeprom[] = {
{ TOH_EEPROM_VENDOR, 2, 0 },
{ TOH_EEPROM_PRODUCT, 2, 2 },
{ TOH_EEPROM_REV, 1, 4 },
{ TOH_EEPROM_EEPROM_SIZE, 2, 5 },
{ TOH_EEPROM_CFG_ADDR, 2, 7 },
{ TOH_EEPROM_CFG_SIZE, 2, 9 },
{ TOH_EEPROM_UDATA_ADDR, 2, 11 },
{ TOH_EEPROM_UDATA_SIZE, 2, 13 },
};

juiceme
2014-01-14, 06:12
Well, 256 bytes don't hold very impressive images or sounds. that's for sure :D

I'd imagine what you can put there is an URL that gets downloaded by the system when you insert the EEPROM, for example. Now you'd need to write up a daemon that gets kicked when an EEPROM of the signature you have gets inserted to I2C...

minimos
2014-01-14, 06:57
An AT24C02 EEPROM with a wopping 256 bytes of data :p

Since EEPROMS are very very easy to program (http://www.cutedigi.com/arduino-shields/i2c-eeprom-for-arduino-256kbit.html), this is a very quick way to make your custom OH instantly very awesome!

256 bytes is about same capacity of the NFC tags. If it's just to recognize the OH wouldn't be better to use those (and spare the energy to power the EEPROM) ?
Otherwise, how does read/write cycles in NFS tags and EEPROMs compare, when they are used to periodically store temporary data?

kimmoli
2014-01-14, 07:59
Remember that the VDD in toh is 3.3V, and I2C levels are 1.8V CMOS, so the EEPROM might not talk with you.

dirkvl
2014-01-14, 09:40
Well, 256 bytes don't hold very impressive images or sounds. that's for sure :D
Well no, that's why I said 'download' image :p Although there are also a lot bigger EEPROMS, I think its power is in simple commands.

how does read/write cycles in NFS tags and EEPROMs compare, when they are used to periodically store temporary data?
Stand-by current of eeprom = 8 micro-amps. Read/write is a bit higher, but write time is a few milliseconds. The thing is, EEPROMs are available and Jolla NFCtags are not. Also, when you are making a PCB for an OH, it is way easier to also put an EEPROM on there instead of also making an NFC tag.

Remember that the VDD in toh is 3.3V, and I2C levels are 1.8V CMOS, so the EEPROM might not talk with you.
I believe EEPROMS are designed with flexibility in mind, so I think this will be okay!

Now you'd need to write up a daemon that gets kicked when an EEPROM of the signature you have gets inserted to I2C...
Ha! See this post (http://talk.maemo.org/showpost.php?p=1396890&postcount=212). Thats the beauty, the phone automatically looks for it.

Anyway, the question was not 'if' but 'how'! What kind of commands could you put on there?

kimmoli
2014-01-14, 11:02
I believe EEPROMS are designed with flexibility in mind, so I think this will be okay!


you wish... with I2C, anything is possible, it is "standard", but implementations varies.

VinHIlow = VCCx0.7V (aka CMOS) and when VCC is 3.3V, means that SDA/SCL needs to be ~2.3V to make sure them to be high.
(Ref AT24C02 datasheet (http://www.atmel.com/Images/doc0180.pdf))

dirkvl
2014-01-14, 14:51
Okay, then i put an regulator in between that outputs 2 volt to the Vcc of the EEPROM, problem solved. At least for trial fase.

dirkvl
2014-01-20, 16:40
In recent developments, the qwerty-oh is upgraded with a 1.8V voltage regulator, which mean I will very probably also stick an EEPROM on there.

Has anyone -by chance- come by some EEPROM commands for Sailfish?

nieldk
2014-01-20, 17:09
In recent developments, the qwerty-oh is upgraded with a 1.8V voltage regulator, which mean I will very probably also stick an EEPROM on there.

Has anyone -by chance- come by some EEPROM commands for Sailfish?

you'll need to create that interface yourself :)
An eeprom is programmed by electric signals on designated addressbusses and will output whatever you put in their. Those instructions can then be used by microcontrollers, or TOH, interpreting the output.

http://www.engineersgarage.com/electronic-components/24c02-eeprom

kimmoli
2014-01-20, 17:45
Simple EEPROM data to try. (Maybe i have nothing else to do tonight)

000: 12 34 56 78 01 01 00 00 30 00 05 00 40 00 06 00
010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
030: 43 46 47 3F 00 00 00 00 00 00 00 00 00 00 00 00
040: 55 44 41 54 41 00 00 00 00 00 00 00 00 00 00 00


Should set following values; These should be then visible somewhere in sysfs


Vendor = 0x1234
Product = 0x5678
Rev = 0x01
EEPROM size = 0x0100 (256 bytes)
CFG address = 0x0030 (must be at least 0x30)
CFG Size = 0x0005 = 5 bytes (at address 0x0030)
Udata address = 0x0040
Udata size = 0x0006 = 6 bytes (at address 0x0040)
config = string "CFG?" (including NULL)
udata = string "UDATA"

kimmoli
2014-01-20, 18:35
ok. whats next?

Got it soldered there, programmed it with my i2ctool (http://talk.maemo.org/showthread.php?t=92329)
and after faking TOH in place with takkatikku

https://lh5.googleusercontent.com/-aIRXwdhNDnI/Ut1uxCb9XqI/AAAAAAAAGUk/YlxpRQaKUP0/w1484-h835-no/14010022.jpg

https://lh6.googleusercontent.com/-ACqVKhLqx4k/Ut1ttjSZ_MI/AAAAAAAAGUU/vxnPpz636i4/w1501-h667-no/kollaasi.jpg

i can see it in /sys/bus/i2c/devices/1-0050

[root@localhost 1-0050]# xxd eeprom
0000000: 1234 5678 0101 0000 3000 0500 4000 0600 .4Vx....0...@...
0000010: ffff ffff ffff ffff ffff ffff ffff ffff ................
0000020: ffff ffff ffff ffff ffff ffff ffff ffff ................
0000030: 4346 473f 00ff ffff ffff ffff ffff ffff CFG?............
0000040: 5544 4154 4100 ffff ffff ffff ffff ffff UDATA...........
0000050: ffff ffff ffff ffff ffff ffff ffff ffff ................
0000060: ffff ffff ffff ffff ffff ffff ffff ffff ................
0000070: ffff ffff ffff ffff ffff ffff ffff ffff ................
0000080: ffff ffff ffff ffff ffff ffff ffff ffff ................
0000090: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000a0: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000b0: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000c0: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000d0: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000e0: ffff ffff ffff ffff ffff ffff ffff ffff ................
00000f0: ffff ffff ffff ffff ffff ffff ffff ffff ................


It appeared in /sys/devices/platform/toh-core.0

And there are all data except 'udata' ?


[root@localhost toh-core.0]# ll
total 0
-r--r----- 1 root root 4096 Jan 20 20:30 cfg_addr
-r--r----- 1 root root 4096 Jan 20 20:30 cfg_size
-r--r----- 1 root root 4096 Jan 20 20:30 config_data
lrwxrwxrwx 1 root root 0 Jan 20 20:27 driver -> ../../../bus/platform/drivers/toh-core
-r--r----- 1 root root 4096 Jan 20 20:30 eeprom_size
-r--r--r-- 1 root root 4096 Jan 20 20:30 microamps_requested_toh-core.0-toh_vdd
-r--r--r-- 1 root root 4096 Jan 20 20:30 modalias
drwxr-xr-x 2 root root 0 Jan 20 20:30 power
-r--r----- 1 root root 4096 Jan 20 20:30 product
-r--r----- 1 root root 4096 Jan 20 20:30 rev
lrwxrwxrwx 1 root root 0 Jan 20 20:27 subsystem -> ../../../bus/platform
-r--r----- 1 root root 4096 Jan 20 20:30 udata_addr
-r--r----- 1 root root 4096 Jan 20 20:30 udata_size
-rw-r--r-- 1 root root 4096 Jan 20 20:27 uevent
-r--r----- 1 root root 4096 Jan 20 20:30 vendor
[root@localhost toh-core.0]# cat *
48
5
CFG?cat: driver: Is a directory
256
0
platform:toh-core
cat: power: Is a directory
22136
1
cat: subsystem: Is a directory
64
6
DRIVER=toh-core
MODALIAS=platform:toh-core
4660
[root@localhost toh-core.0]#

Larswad
2014-01-20, 18:52
So, I found this in my mailbox today:
An AT24C02 EEPROM with a wopping 256 bytes of data :p

Also, they are dirt-cheap.
You are actually a bit wrong on the size. It is 256KB of memory.

It costs $2.73 on dx.com (what did you pay? :D ).
http://dx.com/p/at24c256-i2c-eeprom-storage-module-for-intelligent-car-red-black-213399#.Ut1wNPQRlpU

Here's the specs on the EEPROM circuit:
http://www.atmel.com/Images/doc0670.pdf

kimmoli
2014-01-20, 19:07
You are actually a bit wrong on the size. It is 256Kb of memory.
AT24C256 yes, but no...
We are speaking about AT24C02 which is 2Kbits (256 Bytes)

dirkvl original link was to some arduino page... with example of 256Kb eeprom. I dont know what he has purchased :confused:

Since EEPROMS are very very easy to program (http://www.cutedigi.com/arduino-shields/i2c-eeprom-for-arduino-256kbit.html),...

Here's the specs on the EEPROM circuit:
http://www.atmel.com/Images/doc0670.pdf
AT24C02 http://www.atmel.com/Images/doc0180.pdf

AT24C256 is not supported as it uses two-byte data-word-addressing mode.
Jolla toh seems (afaik) to support only one-byte data-word-addressing mode.

(EDIT: I paid 0,27€ each at digikey)

kjokinie
2014-02-04, 19:08
Hi,

I just thought I post some of my personal notes here about the eeprom stuff in the toh driver (having written the driver).

The idea originally was to

1. Have some way to automatically instantiate devices to linux kernel (to allow true linux "device-driver" model hot plugging of devices)
2. Have system and application specific configurations provided for userspace (and to some extent kernel)

For system configurations we tried bitmasks and such, but finally converged to just a configuration string (CFG_DATA). Idea there was to have some pre-defined key-value pairs to initiate actions inside kernel and tohd. Simple exaple would be vdd=1, meaning "enable the VDD". Or have some other string for i2c device parameters that the toh-core driver would register onto the bus then (so that corresponding driver would automatically probe).

The user data was meant for any application running in userspace to just read and do anything they need to according to that.

But... At some point of development we shifted gears and went full speed for the NFC based identification and the EEPROM was left a bit unattended. I basically got the CFG_DATA exporting done, but none of the hotplugging things nor exporting user data.

I thought the EEPROM still could serve a purpose for hacker community, as you can (maybe) more easily (and independently of Jolla store or anything outside) do simple detection of your own custom cover. So the driver is still there, but it's not "officially" driven forward at the moment. But were not removing it either, so feel free to use in personal hacking :)

I'm very interested to see what kind of uses you guys come up with it. Maybe once the recovery options allow safe community kernel development on Jolla, something in form of quality kernel patches could arise that we could pick up into official release as well.

kimmoli
2014-02-04, 20:01
Idea there was to have some pre-defined key-value pairs to initiate actions inside kernel and tohd. Simple exaple would be vdd=1, meaning "enable the VDD". Or have some other string for i2c device parameters that the toh-core driver would register onto the bus then (so that corresponding driver would automatically probe).

at dayjob, we use something like this to set additional Linux environment variables from external configuration memory.

The user data was meant for any application running in userspace to just read and do anything they need to according to that.

Is the UDATA somewhere accessible, could not find that the driver makes it visible in sysfs?

And atm to get the automatic rpm download/install, the NFC is the only way?

I'm very interested to see what kind of uses you guys come up with it.


I will anyway have a eeprom on my TOHs, maybe use to store some TOH identity or TOH dependent configurations, e.g. if oled toh would have different settings (brightness/font etc) this is stores on eeprom. or serial number, hw version information, sensor calibration data.

kimmoli
2014-08-19, 19:01
Example udev rule: /etc/udev/rules.d/95-toholed.rules
KERNEL=="toh-core.0", ATTR{vendor}=="19276", ATTR{product}=="2", ACTION=="add", RUN+="/bin/systemctl start harbour-toholed"
KERNEL=="toh-core.0", ACTION=="remove", RUN+="/bin/systemctl stop harbour-toholed"


udevadm info:
looking at device '/devices/platform/toh-core.0':
KERNEL=="toh-core.0"
SUBSYSTEM=="platform"
DRIVER=="toh-core"
ATTR{rev}=="1"
ATTR{cfg_addr}=="48"
ATTR{cfg_size}=="5"
ATTR{eeprom_size}=="256"
ATTR{microamps_requested_toh-core.0-toh_vdd}=="0"
ATTR{config_data}=="CFG?"
ATTR{vendor}=="19276"
ATTR{udata_addr}=="64"
ATTR{udata_size}=="6"
ATTR{product}=="1"

kimmoli
2014-08-19, 19:07
Cross-linking:

vendor and product id's in TJC wiki https://together.jolla.com/question/53927/toh-eeprom-vendor-and-device-id/