How to write to registers over i2c in u-boot - ethernet

I am a hardware guy with little embedded systems experience, so my question may be trivial.
I need to put an Ethernet switch in "test mode 1" which is an Ethernet compliance test mode you can put the chip in for characterizing signals on a scope. at the bottom is the datasheet page that shows this register and how to put it in test mode 1.
I am using u-boot i2c commands to do this.
chip Slave address = 0x5F
Port 1 address (to be written to) = 0x1112.2 (16 bit address needs the .2, correct me if i am wrong)
I send the following command to the switch:
#i2c mw 0x05F 0x1112.2 0x01 10
Then I read it back:
#i2c md 0x05F 0x1112.2 10
1112: 01 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 ............0...
The command that I am writing is only writing to the first bit. I cant for the life of me figure out how to write to any other bit at that address other than the first one. What would my u-boot i2c command look like if I wanted to set bits [15:13] to [0 0 1]?

Related

Raspberry Pi SPI fault - returning incorrect bits

I'm currently trying to interface a cs5530 ADC to a raspberry pi 4b 8g using SPI. When I attempt to communicate with the ADC I repeatly get return bits that make no sense and am running out of ideas to trouble shoot. When using the Spidev-test script I'm recieving the following response:
spi mode: 0x4 bits per word: 8 max speed: 2000000 Hz (2000 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF F0 0D
RX | FF FF FF FF FF FF FF F8 00 00 00 27
F8 00 00 00 27 F8 00 00 00 27 FF FF FF FF FF FF FF FF FF FF
As you can see there's something causing the MISO line to be recieving incorrect bits. If I use a jumper from MOSI to MISO to the bits return as should be expected. I've tried different clk speeds while staying under 2MHz as that is specified as the max clk speed in the cs5530 data sheet. I'm also recieving similar junk back using the spidev libary in python.
I'm thinking the most likely problem I have is for some reason the clk on the rpi isn't producing a proper signal. I don't own a logic analyser (thinking I'll properlly have to order one) so I've mapped the signal the best I can using piscope.
this image shows what looks like to me the clk line not functioning as you should expect.
I'm a novice at this sort of thing but it looks to me that the clk line is all over the show instead of regular sine wave you'd expect to see there. I'm not sure if this is what's casuing me issues or if it's due to the limitations of piscope.
this image also shows similar behaviour happening when I'm shorting MOSI and MISO to test the lines.
So while I think I've found the cause of my issues I'm about out of ideas of what could be causing this issue and how to fix it. So far all the things I've tried when trying to troubleshoot this is:
Swapping out Raspberry Pi's - Problem presists exactly the same.
Swapping out cs5530
checked all my solders on the prototyping board and continuity between all points, test resistor values and cap's are all at correct values. Swapped crystals due to not having a scope to test it.
Tested the cs5530 at both 3v and 5v modes (using an external power supply)
Grounded rpi to external power supply
Tried running a cs5530 off rpi 3.3v supply
set core_freq=250 on rpi
set dvfs=2 to rpi to prevent any issues caused by core being under voltaged
tested on spi0 (CE 0 and 1) and spi1
temp was 53 degrees when the tests in the pictures where done so I think I can rule out thermal throttling as well. At this point I'm completely out of ideas what else to try. Might be worth noting that I am booting off a high quality 16gb USB flash drive, I haven't bothered coping the img to a sd card just yet as I wouldn't have thought that this would be causing any problems but I might try it just to fully rule that possiblity out.
link for cs5530 datasheet : Cs5530 Datasheet
Thanks in advance for any help, hoping that there's someone much smarter than me out there that can shine some light on this for me.
Cheers

BLE Communication Protocol T1S (Smart Band) Get Data

I want to communicate my android app to this smart band (T1S), I've already paired it, but I don't know how to extract data from it, such as temperature, etc.
I got the characteristics and services from it:
{"name":"T1S","id":"F4:C3:33:99:21:5D","advertising":{},"rssi":-78,"services":["1801","1800","6e400001-b5a3-f393-e0a9-e50e24dcca9e","1812","fee7"],"characteristics":[{"service":"1801","characteristic":"2a05","properties":["Broadcast","Read","Write","Notify","Indicate","AuthenticateSignedWrites"],"descriptors":[{"uuid":"2902"}]},{"service":"1800","characteristic":"2a00","properties":["Read"]},{"service":"1800","characteristic":"2a01","properties":["Read"]},{"service":"1800","characteristic":"2a02","properties":["Read"]},{"service":"1800","characteristic":"2a04","properties":["Read"]},{"service":"1800","characteristic":"2aa6","properties":["Read"]},{"service":"6e400001-b5a3-f393-e0a9-e50e24dcca9e","characteristic":"6e400003-b5a3-f393-e0a9-e50e24dcca9e","properties":["Notify"],"descriptors":[{"uuid":"2902"}]},{"service":"6e400001-b5a3-f393-e0a9-e50e24dcca9e","characteristic":"6e400002-b5a3-f393-e0a9-e50e24dcca9e","properties":["WriteWithoutResponse","Write"]},{"service":"1812","characteristic":"2a4e","properties":["Read","WriteWithoutResponse"]},{"service":"1812","characteristic":"2a4d","properties":["Read","Write","Notify"],"descriptors":[{"uuid":"2902"},{"uuid":"2908"}]},{"service":"1812","characteristic":"2a4d","properties":["Read","Write","Notify"],"descriptors":[{"uuid":"2902"},{"uuid":"2908"}]},{"service":"1812","characteristic":"2a4d","properties":["Read","Write","Notify"],"descriptors":[{"uuid":"2902"},{"uuid":"2908"}]},{"service":"1812","characteristic":"2a4b","properties":["Read"]},{"service":"1812","characteristic":"2a33","properties":["Read","Write","Notify"],"descriptors":[{"uuid":"2902"}]},{"service":"1812","characteristic":"2a4a","properties":["Read"]},{"service":"1812","characteristic":"2a4c","properties":["WriteWithoutResponse"]},{"service":"fee7","characteristic":"fec9","properties":["Read","Notify"],"descriptors":[{"uuid":"2902"}]},{"service":"fee7","characteristic":"fea1","properties":["Read","Indicate"],"descriptors":[{"uuid":"2902"}]},{"service":"fee7","characteristic":"fea2","properties":["Read","Write","Indicate"],"descriptors":[{"uuid":"2902"}]}]}
I've analyzed another android apps and I captured received and sended bluetooth data with this smart band and my phone with Wireshark and bluetooth-log to know what data or protocols are transmitted to get the temperature, I'm sure that the response of temperature is:
0000 02 02 20 14 00 10 00 04 00 1b 12 00 ab 00 0a ff ..
............. 0010 51 13 14 06 05 06 37 24 05
Q.....7$.
But I don't know how to convert this response to actual temperature in C°, somebody knows how to extract the real data from this smart band?
thanks in advance.
smart band link:
https://www.alibaba.com/product-detail/Cheap-High-Quantity-Bluetooth-Smart-Bracelet_1600057978967.html?spm=a2700.icbuShop.111720.6.54226ef9FPTgvq
const readCharacteristic = await device.readCharacteristicForService(userDataServiceUUID, heightCharacteristicUUID); // assuming the device is already connected
const heightInCentimeters = Buffer.from(readCharacteristic.value, 'base64').readUInt16LE(0);
https://github.com/Polidea/react-native-ble-plx/wiki/=--FAQ:-Passing-And-Retrieving-Of-Characteristic-Value

Unable to lowering the raspberry pi Bluetooth transmition power

I'm trying to turn my raspberry to an iBeacon but I cannot make it transmit with lower power, I've changed Tx power many times, when I use my BLE scanner I see that Tx power has changed but RSSI hasn't at all while with other beacon devices changing transmission power leads to a lower powered measure. Has anyone had the same problem? this is the command that I run.(I've changed C8 to 88, CE, E7 and etc.)
sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8
The byte you are changing does not control the strength of the output of the transmitter. That byte is referred to by either "tx power" or "measured power". There latter term is more accurate. It is used to communicate to receivers what the expected rssi should be at a range of 1 meter to aid in distance estimates. Again, changing it does not actually change the strength of the transmitter.
Unfortunately, there is no API in the raspberry Pi to alter the strength of the Bluetooth transmitter.

Online CRC-32 calculator result is incorrect, wrong polynomial?

I have to say that I don't really understand the mechanics of CRC-32; but I was hoping to be able to at least calculate a CRC based on a chunk.
I have a PNG with the following information: 2px by 5px, RGBa, no interlace
The image header chunk results in:
00 00 00 0d = data is 13 bytes long
49 48 44 52 = ascii for IHDR (image header)
00 00 00 02 00 00 00 05 08 06 00 00 00 = data; dimensions, bit-depth, etc.
6f b3 3d 9c = CRC
I wanted to see if CRC could be easily calculated so I tried using:
http://depa.usst.edu.cn/chenjq/www2/wl/software/crc/CRC_Javascript/CRCcalculation.htm
The calculator's default polynomial for CRC-32 is 04C11DB7.
When I plug in "0000000d4948445200000002000000050806000000" I get 35F0A255.
I looked it up on Wikipedia and tried the other various representations used by PNG (EDB88320 & 82608EDB) and I tried leaving off the length and chunk type with the various polynomials I used before; I also tried including the information before the chunk which defines the PNG signature. I never got 6fb33d9c.
Any ideas on why I can't get the right CRC via calculator?

Storing unicode code points, high-endian or low-endian mode?

In his famous blog post The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) Joel said :
The earliest idea for Unicode encoding, which led to the myth about
the two bytes, was, hey, let's just store those numbers in two bytes
each. So Hello becomes
00 48 00 65 00 6C 00 6C 00 6F
Right? Not so fast! Couldn't it also be:
48 00 65 00 6C 00 6C 00 6F 00 ?
The second representation is faster ? why ?
How does swapping the high and low bytes affect performance ?
The sentence "Not so fast!" isn't about computing performance but a way to say "hey, don't make assumptions so fast, here's another way to look at it".
The question is Mu.