Raspberry Pi 3 USB Bare Metal - raspberry-pi

I am working on the new Raspberry Pi 3 B+ board in a bare metal environment (32-bit). I have a working USB driver for the older Pi 1 boards. From what I understand, the Pi 1 and the Pi 3 B+ have the same USB host controller (Synopsis DesignWare 2.0 USB Host Controller; or dwc for short), yet the USB driver that works on the Pi 1 does not work for me on the Pi 3 B+ (or the Pi 3 B either).
After going through some debugging messages, I found that the problem is that when the DWC is enumerating the devices, it will try to read the device descriptor of, what I am guessing is, the on-board USB hub/ethernet device (LAN7515), but it will return a transfer error, and then therefore is unable to enumerate the device.
My question is why does this happen? If the Pi 1 and the Pi 3 have the same host controller then it should, in theory, at least be able to properly enumerate a device.
If someone can point me in the right direction as to why this happens, it would be greatly appreciated.
Thank you in advance.

The Pi3 is having an alignment issue because some of the USB structures are not natively aligned and they are packed. It generally requires inserting some pack and alignment attributes "attribute((packed, aligned(1)))" on some of the structures that are unaligned.
The rule goes
uint16_t* pointers must be reading/writing align 2 addresses
uint32_t* pointers must be reading/writing align 4 addresses
So a struct like this is misaligned.
struct BadStruct __attribute__((__packed__)){
uint8_t a;
uint16_t b;
};

Related

raspberry pi gpio or rs232 relay board for simultaneous output bit-map?

I really wanted at first an rs232 8-channel relay board that I could command devices to turn on/off with a command string.
All of the ones I found online have the same deficiency in functionality for me: you can't set a subset of relays at the exact time. I can set relay 1 on, and then relay 7 on afterwards, I can set all 8 relays at once, but there is no command structure to pick out the exact leds I would like to turn on/off.
In the past I have dealt with hardware that had a bit-map of the IO pins, and a bit-map of the states and would apply all 8 settings at once. here are some examples:
to set pins 1 and 7 to on and the other pins off (8-bit binary bit-mapping,) send the following byte: in binary: 0100 0001b
to set pins 1,2,3,6 to on and the other pins off (8-bit binary bit-mapping,) send the following byte: in binary: 0010 0111b
I couldn't find any such device to do this so I thought I could make one with a raspberry pi using a simple 8-channel relay board, something like this:
https://www.amazon.com/SainSmart-101-70-102-8-Channel-Relay-Module/dp/B0057OC5WK
but on a Raspberry Pi, I'm running into the same issue: I don't see a way to set the gpio pins as a block command, only individually setting them in a for loop. I looked all morning and can see things like gpioctl, and mmio, but I can't put it all together to a simple proof of concept program on a testboard, any help would be appreciated.
I would really like a solution in C or scripting,
Thanks,
jleslie

Am I slowing down my Raspberry Pi Zero W by setting cpu_freq=250?

I use this library over SPI to control some RGB Leds.
When using the Raspberry Pi 3, I have to set cpu_freq=250 on /boot/config, as far as I've understood, it has something to do with the bluetooth device running on the default serial port.
Now, using the Raspberry Pi Zero W I'm algo having to set that flag.
My questions is, what is the correct cpu clock for both Pi 3 and Zero W, and am I slowing my Pi performance by setting this flag?

Raspberry Pi Zero I2C pull up + GY-521

I'm trying to talk via I2C to the gyro sensor MPU6050 which sits on a GY 521 board. But i can't get the device being detect.
I tested another i2c device (EEPROM) and got the device address detected. So i guess it has to be a hardware problem.
As far as i could find out:
RPi has a 1.8k pullup resistor on SDA and SLC already on board
my GY 521 also has also a pullup resistor (2.2k) on each line on board
Could the resistors be the problem? A good resistor value in sum would be around 5k on each line?
(The wiring should be ok, there are a lot of instructions around the net and i've checked it multiple times. I use 5v on the GY521 since it has a voltage converter)
Any help appreciated!
The problem was bad soldering.
For the record:
Using the RPi pullups in combination with the breakout board pullups works for me.

Interfacing ds18b20 with raspberry pi

i have a raspberry pi connected with two ds18b20 temperature sensor.
-sensor1 is fixed on the outside of my garage (distance 20m from raspberry pi)
-sensor2 is just connected in a breadboard near the raspberry pi.
Everything is working well.
I decided to add sensor3 located outside and from 20m from the raspberry pi.
Now when i type :
cd /sys/bus/w1/devices
if find this:
c0-40a000061005 c2-246056869800 c2-247056869000 d0-008000001000 w1_bus_master1
instead of :
28-.....
28-.....
28-.....
each sensor ref should be start with 28-.....
what is happening with my sensors?
If unplugged the sensor1, then everything is well
if i unplug the sensor3 and let only sensor1 and sensor2 everything is well.
Which modification do we have to do when sensor are located far from the raspberry pi?
thank you
That means that the 3rd sensor doesn't have a 4.7kOhm or 10kOhm resistor between VCC and the OUT wire (black/red one if you have 4wire DS18B20).
Just connect that resistor and it will work , I had the same problem . I spent weeks to find such an easy solution. And if you get the same code after you connected the resistor , that means you didn't connected it properly.Hope will help you

Raspberry B+ Power Supply calculation

I'm new to Raspberry Pi and I don't understand about electricity. I bought a Raspberry B+ today and a 5V 3A power supply, but I'm afraid to connect it because in several places I read about using 5V 2A power supplies. I believe that only higher voltages can damage the Pi but, since I don't know about Amp, I don't know if this is true for 3A too.
My ideia is create a mini-personal server in my home, running Pidora. For data, I have a 1 Tb external USB drive with no external power supply (Seagate model SRD00F1).
My questions are:
can I use the 5V 3A power supply on Raspberry Pi B+ without damage it?
this power supply is compatible with my external USB drive to keep it on safely?
Thank you!
The Raspberry Pi FAQ says that the B+ uses between 0.7 and 1.0 amps, and suggest a 1.2 amp power supply as a minimum.
Using a power supply with a higher amperage rating will not harm your Raspberry Pi. Devices only draw as much current (amperage) as they need. Any additional capacity is unused.
This is where your question about the external hard drive comes in. If you see in the FAQ, they suggest that you might want a larger power supply if you use all of the USB ports. Every USB device you plug in is going to draw more current. To figure out how much you need, you just add up the requirements of all of the devices like so:
Raspberry Pi = 0.7-1.0A
Mouse/Keyboard = 0.5A
Hard Drive = 1.0A
========================
TOTAL = 2.5A
(These numbers are all fake... be sure to check the requirements for your actual devices.)
So if your devices total 2.5A then a 3A supply will handle all of these plus some room for expansion. If all of your devices total 3.5A, maybe you need to consider a bigger one.