maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   The Other Half (https://talk.maemo.org/forumdisplay.php?f=59)
-   -   Commands on EEPROM (https://talk.maemo.org/showthread.php?t=92405)

dirkvl 2014-01-13 22:14

Commands on EEPROM
 
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, 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

Re: Commands on EEPROM
 
Also, GITHUB has this page

Quote:

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

Re: Commands on EEPROM
 
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

Re: Commands on EEPROM
 
Quote:

Originally Posted by dirkvl (Post 1406236)
An AT24C02 EEPROM with a wopping 256 bytes of data :p

Since EEPROMS are very very easy to program, 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

Re: Commands on EEPROM
 
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

Re: Commands on EEPROM
 
Quote:

Originally Posted by juiceme (Post 1406281)
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.

Quote:

Originally Posted by minimos (Post 1406286)
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.

Quote:

Originally Posted by kimmoli (Post 1406298)
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!

Quote:

Originally Posted by juiceme (Post 1406281)
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. 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

Re: Commands on EEPROM
 
Quote:

Originally Posted by dirkvl (Post 1406314)
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)

dirkvl 2014-01-14 14:51

Re: Commands on EEPROM
 
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

Re: Commands on EEPROM
 
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

Re: Commands on EEPROM
 
Quote:

Originally Posted by dirkvl (Post 1407716)
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/elect...s/24c02-eeprom

kimmoli 2014-01-20 17:45

Re: Commands on EEPROM
 
Simple EEPROM data to try. (Maybe i have nothing else to do tonight)

Code:

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

Re: Commands on EEPROM
 
ok. whats next?

Got it soldered there, programmed it with my i2ctool
and after faking TOH in place with takkatikku

https://lh5.googleusercontent.com/-a...o/14010022.jpg

https://lh6.googleusercontent.com/-A...o/kollaasi.jpg

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

Code:

[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' ?

Code:

[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

Re: Commands on EEPROM
 
Quote:

Originally Posted by dirkvl (Post 1406236)
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-...9#.Ut1wNPQRlpU

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

kimmoli 2014-01-20 19:07

Re: Commands on EEPROM
 
Quote:

Originally Posted by Larswad (Post 1407741)
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:
Quote:

Originally Posted by dirkvl (Post 1406236)
Since EEPROMS are very very easy to program,...

Quote:

Originally Posted by Larswad (Post 1407741)
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

Re: Commands on EEPROM
 
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

Re: Commands on EEPROM
 
Quote:

Originally Posted by kjokinie (Post 1410950)
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.

Quote:

Originally Posted by kjokinie (Post 1410950)
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?

Quote:

Originally Posted by kjokinie (Post 1410950)
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

Re: Commands on EEPROM
 
Example udev rule: /etc/udev/rules.d/95-toholed.rules
Code:

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

Re: Commands on EEPROM
 
Cross-linking:

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


All times are GMT. The time now is 02:14.

vBulletin® Version 3.8.8