The Serval Mesh Extenders logically consist of a CPU with a serial port, and an RFD900 radio. Our RFD900 firmware provides a regular heart-beat.
This all means that the RFD900 radio, as soon as it powers on, begins sending heart-beat messages.
This ordinarily wouldn't be a problem, except that the CPU modules we are using have only one serial port, so the serial boot loader is listening on the serial port when the system first powers up, and whenever it resets.
This means that if uboot sees a heartbeat, it will interpret it as the user wishing to interrupt the boot process to interact with the boot loader. Following Murphey's Law, this is assured to happen on every boot.
We can't get rid of uboot, as it is important to have a way to reflash the devices (especially while we are still developing the software for them).
The remaining solution is to teach the RFD900 to notice when uboot is active.
In theory, this would just take a simple little finite state machine to notice the uboot banner, and then make sure it doesn't send any characters for a while, to allow uboot to boot normally.
There are, however, two complications.
1. We have to stay silent for long enough that we don't interfere with OpenWRT's fail-safe boot mode, which just means staying silent for longer.
and
2. The RFD900 is set to 230400bps for talking to LBARD, while uboot uses the serial port at 115200.
It is this last problem that makes life more interesting, because we can't just watch for the characters of the uboot banner. Instead, we need to look for a character sequence at 230400bps that is what you would see if you send the uboot banner at 115200bps.
As uboot is working at 1/2 the baud rate that the RFD900 is using, every serial bit received from uboot will be interpreted as two bits. Thus each uboot serial character should be able to be reliably received as two characters by the RFD900. We're lucky it isn't the other way around, as then the bits would be only half as wide, and there would be some uncertainty about how the bits would be read.
In the process, I also had to clean up a few other spots where our RFD900 firmware was causing other characters to be emitted immediately on power-up.
So after a few frustrating hours of debugging the finer points, I can now reliably boot a uboot-based system with an RFD900 running our packet radio firmware permanently attached to the serial port.
Tuesday, March 28, 2017
Wednesday, March 15, 2017
The custom IP67 power cables have arrived!
So, just over ten days ago I wrote that a Chinese manufacturer said that they could manufacture and ship the cables we want within ten days, and that I would order some. Today they arrived! Some fun unpacking photos:
First up, I must congratulate the Chinese manufacturer for being able to manufacture and ship our order so quickly. They really were a pleasure to work with, including when we had a minor problem with the shipping (which wasn't their fault).
Also, as the photos hopefully show, the cables are very solidly built, with much thicker wire than the little ones we were contemplating using previously. They will be able to easily support large panels and batteries, with charge currents being limited only by the battery charge controller inside the Mesh Extender. The cables simply give the strong impression that they will do the job well, which we will test over coming months.
The only complication we encountered, was that they didn't have stock of the white cable material, so we had to opt for the black PVC cable, which will slightly increase heat loading of the Mesh Extenders. But given the time frames that we are working to at the moment, we needed to simply be sure that we would have the cables we need, so that we can get the cable head moulding tools made and cables assembled in time. Critical paths are everything when building hardware!
First up, I must congratulate the Chinese manufacturer for being able to manufacture and ship our order so quickly. They really were a pleasure to work with, including when we had a minor problem with the shipping (which wasn't their fault).
Also, as the photos hopefully show, the cables are very solidly built, with much thicker wire than the little ones we were contemplating using previously. They will be able to easily support large panels and batteries, with charge currents being limited only by the battery charge controller inside the Mesh Extender. The cables simply give the strong impression that they will do the job well, which we will test over coming months.
The only complication we encountered, was that they didn't have stock of the white cable material, so we had to opt for the black PVC cable, which will slightly increase heat loading of the Mesh Extenders. But given the time frames that we are working to at the moment, we needed to simply be sure that we would have the cables we need, so that we can get the cable head moulding tools made and cables assembled in time. Critical paths are everything when building hardware!
Sunday, March 5, 2017
Sourcing cables directly from a Chinese manufacturer
I'm still working on the power/radio-regulatory cable for the Mesh Extenders. Fortunately, this process is drawing towards its natural ending.
My current challenge is to find suitable UV-stable and IP65 or better rated cables.
We have already found some on banggood.com, but they leads are only ~20cm long. I'd much prefer leads approximately 0.5m - 1m long, so that there is ample length for attaching solar panels and battery packs, and general ease of connection.
A bit of hunting on http://alibaba.com yielded an enquiry from Bett Electronic Co. LTD in Shenzhen.
They have exactly the kind of thing we are looking for, and nicely, their cables are thicker (18-AWG instead of 22-AWG and 24-AWG) than the ones we found on BangGood, which means lower resistance. A further bonus, is that they can manufacture in white, which will reduce heat loading a touch. Their cables are also IP67 certified. Also very nice. Here are the pictures that they sent of a sample:
Also, as the manufacturer, their prices are quite good. Given that we are looking for cables that are 87cm long on average (compared with 20cm), and with the heavier-duty wiring, it is pleasing that the price is only about 50% higher. They can also manufacture and ship quite quickly, apparently being able to get 100 units to us within about 10 days, including shipping by DHL.
So the only complication is that they don't have any certification of UV performance that I could use to easily determine whether they would be suitable. However, Leah was very helpful and patient in answering my many, many questions.
What I now know is that the white cables are EPDM with added Titanium Oxide, which should have excellent UV and weathering properties. The connectors themselves are PVC, without any special UV stabilising material. However, according to this document, the main problem with PVC under UV, is that it will discolour (not a problem), and will have reduced impact resistance (only a minor problem).
Otherwise, the only minor issue, is that I can't figure out if the PVC is Lead-free or not. However, given the small mass of the connectors, this is not an immediate concern. Nonetheless, I would love to be able to be sure that there was no Lead in the PVC.
So it looks like we have a good solution, and I think I will place the order with Bett Electronic in the next day or so.
My current challenge is to find suitable UV-stable and IP65 or better rated cables.
We have already found some on banggood.com, but they leads are only ~20cm long. I'd much prefer leads approximately 0.5m - 1m long, so that there is ample length for attaching solar panels and battery packs, and general ease of connection.
A bit of hunting on http://alibaba.com yielded an enquiry from Bett Electronic Co. LTD in Shenzhen.
They have exactly the kind of thing we are looking for, and nicely, their cables are thicker (18-AWG instead of 22-AWG and 24-AWG) than the ones we found on BangGood, which means lower resistance. A further bonus, is that they can manufacture in white, which will reduce heat loading a touch. Their cables are also IP67 certified. Also very nice. Here are the pictures that they sent of a sample:
Also, as the manufacturer, their prices are quite good. Given that we are looking for cables that are 87cm long on average (compared with 20cm), and with the heavier-duty wiring, it is pleasing that the price is only about 50% higher. They can also manufacture and ship quite quickly, apparently being able to get 100 units to us within about 10 days, including shipping by DHL.
So the only complication is that they don't have any certification of UV performance that I could use to easily determine whether they would be suitable. However, Leah was very helpful and patient in answering my many, many questions.
What I now know is that the white cables are EPDM with added Titanium Oxide, which should have excellent UV and weathering properties. The connectors themselves are PVC, without any special UV stabilising material. However, according to this document, the main problem with PVC under UV, is that it will discolour (not a problem), and will have reduced impact resistance (only a minor problem).
Otherwise, the only minor issue, is that I can't figure out if the PVC is Lead-free or not. However, given the small mass of the connectors, this is not an immediate concern. Nonetheless, I would love to be able to be sure that there was no Lead in the PVC.
So it looks like we have a good solution, and I think I will place the order with Bett Electronic in the next day or so.
Wednesday, March 1, 2017
Reading and writing the I2C EEPROM connected to an RFD900
As previously described, for the new Mesh Extender we have an I2C EEPROM for encoding regulatory information, e.g., radio permitted frequency and TX power.
Basically, I am building the tools that we will need to program Mesh Extender cables as we build them, and also in the field, to reprogram them as required.
Over the past couple of weeks I have worked on the code for the RFD900+ firmware to be able to read and write the I2C EEPROM, and then to modify our flash900 utility to be able to flash not just an RFD900 radio, but also an I2C EEPROM connected via an RFD900 radio.
I've had it mostly working for a while now, but there have been strange problems with accessing certain parts of the EEPROM, and weird intermittent write problems affecting the whole EEPROM. I tried swapping EEPROMs, to confirm that it wasn't a faulty part.
I spoke to the engineering workshop folks here, who suggested that I might need external pull-up resisters to terminate the I2C bus, which fortunately turned out not to be the case, as this simplifies the cable and PCB design process (one of them would have required some extra resisters).
They also had a nice little logic analyser that could understand I2C. That proved to be super-helpful. It took me less than an hour to see that the problem was when back-to-back page reads were occurring and the last bit of the last byte read was a zero. Basically I was failing to implement the NACK required at the end of a multi-byte read sequence.
I fixed this by inserting a dummy read with NACK, like this:
$ git show 490025c33a3e821aab05055d627d192bb0d186fc
commit 490025c33a3e821aab05055d627d192bb0d186fc
Author: gardners <paul@servalproject.org>
Date: Thu Mar 2 14:02:22 2017 +1030
properly terminate sequential read operations
diff --git a/Firmware/radio/i2c.c b/Firmware/radio/i2c.c
index 76fe0be..6e9d68f 100644
--- a/Firmware/radio/i2c.c
+++ b/Firmware/radio/i2c.c
@@ -183,6 +183,9 @@ char _eeprom_read_page(unsigned short address)
}
}
+ // Terminate the sequential read
+ i2c_rx(0);
+
i2c_stop();
return 0;
With that in place, I could suddenly reliably access the whole EEPROM. In fact, the correct data was always written there, it was just that I couldn't read it.
Following that, I spent a bit of time optimising the EEPROM read and write speed, and also the speed of the flash-rfd900 utility, both for flashing the radio and flashing the EEPROM.
It is now possible to flash an RFD900 radio in about 23 seconds, even when using a USB serial adapter with 16ms latency. This is a huge improvement on the ~100 - 150 seconds it took previously.
Flashing the I2C EEPROM takes just under 20 seconds, including reading the entire EEPROM once before hand, and once after, to verify that all bytes have been correctly written.
Now I just need to tweak the format of the data that I store in the EEPROM, so that it contains all the information that I need, principally the list of countries a particular cable is suitable for, and increasing the resolution of the frequency parameter from MHz to KHz.
Basically, I am building the tools that we will need to program Mesh Extender cables as we build them, and also in the field, to reprogram them as required.
Over the past couple of weeks I have worked on the code for the RFD900+ firmware to be able to read and write the I2C EEPROM, and then to modify our flash900 utility to be able to flash not just an RFD900 radio, but also an I2C EEPROM connected via an RFD900 radio.
I've had it mostly working for a while now, but there have been strange problems with accessing certain parts of the EEPROM, and weird intermittent write problems affecting the whole EEPROM. I tried swapping EEPROMs, to confirm that it wasn't a faulty part.
I spoke to the engineering workshop folks here, who suggested that I might need external pull-up resisters to terminate the I2C bus, which fortunately turned out not to be the case, as this simplifies the cable and PCB design process (one of them would have required some extra resisters).
They also had a nice little logic analyser that could understand I2C. That proved to be super-helpful. It took me less than an hour to see that the problem was when back-to-back page reads were occurring and the last bit of the last byte read was a zero. Basically I was failing to implement the NACK required at the end of a multi-byte read sequence.
I fixed this by inserting a dummy read with NACK, like this:
$ git show 490025c33a3e821aab05055d627d192bb0d186fc
commit 490025c33a3e821aab05055d627d192bb0d186fc
Author: gardners <paul@servalproject.org>
Date: Thu Mar 2 14:02:22 2017 +1030
properly terminate sequential read operations
diff --git a/Firmware/radio/i2c.c b/Firmware/radio/i2c.c
index 76fe0be..6e9d68f 100644
--- a/Firmware/radio/i2c.c
+++ b/Firmware/radio/i2c.c
@@ -183,6 +183,9 @@ char _eeprom_read_page(unsigned short address)
}
}
+ // Terminate the sequential read
+ i2c_rx(0);
+
i2c_stop();
return 0;
With that in place, I could suddenly reliably access the whole EEPROM. In fact, the correct data was always written there, it was just that I couldn't read it.
Following that, I spent a bit of time optimising the EEPROM read and write speed, and also the speed of the flash-rfd900 utility, both for flashing the radio and flashing the EEPROM.
It is now possible to flash an RFD900 radio in about 23 seconds, even when using a USB serial adapter with 16ms latency. This is a huge improvement on the ~100 - 150 seconds it took previously.
Flashing the I2C EEPROM takes just under 20 seconds, including reading the entire EEPROM once before hand, and once after, to verify that all bytes have been correctly written.
Now I just need to tweak the format of the data that I store in the EEPROM, so that it contains all the information that I need, principally the list of countries a particular cable is suitable for, and increasing the resolution of the frequency parameter from MHz to KHz.
Subscribe to:
Posts (Atom)