Category Archives: Uncategorized

The Mighty T3

FriendlyArm NanoPC T3Some time ago, I wrote about the FriendlyArm NanoPi M1, a simple, low cost board which seems to hold it’s own against the Raspberry Pi2 in all but GPIO control – that’s not to say there is anything wrong with the GPIO but you have to write your own stuff for it as there is (so it would seem) nothing remotely like PIGPIO for these or similar machines. PLEASE prove me wrong.

See updates to this article at the end….

So that’s all fine but what if you need something more meaty? The FriendlyArm NanoPC T3 is a 64 bit octa-core board of similar size to the Pi and where the M1 scored a benchmark similar to the Pi2, the T3 is nearly twice as fast and has a lot more going for it – but then, it is also more expensive. When I say TWICE as fast – that’s doing the same benchmark – if the benchmark made use of all eight cores then the difference could be considerably greater. I've also reviewed the NanoPC T2 but my recent conclusions on that, at least for Android were not too good, certainly not for media consumption. In fact, as of now, I would say NOT to use the T2 as a media centre. See later comments in here.

Like the M1 I’ve managed to get Debian with all my usual tools running on it, really without any great problems. So what’s so special about this one?

It has an A53 Octacore processor, running at 1.4Ghz, with 8Gb of eMMC internally and of course you can use an SD. Unlike most other boards it has 1Gbps Ethernet along with WiFi 802.11b/g/n and Bluetooth 3 dual mode.

Along with that we have 1GB RAM, the facility to handle one of the company’s inexpensive LCD touch display boards, serial debug, RTC interface, 4 USB ports, camera interface, HDMI and supports Android 5.1 (yes with Playstore, unlike the M1 which for some inexplicable reason also support a much earlier Android but with no Playstore – so I just ignored that option - pretty useless really), Debian and Ubuntu.

I set mine up with Debian as usual, used my script to put all my usual stuff on and left it happily sitting in a corner running Node-Red for days - worked a treat.

On the GPIO front – there is some C code available and accessing the ports is fairly straight-forward but it requires root access and we really do need a better way.

Incidentally the unit I have, has a heatsink. Recommended.

There is a microphone input as well – and audio output can go to hdmi or the 3.5mm stereo jack. I already have a T2 model sitting running Android and ImperiHome as a kind of desktop status display – this one may end up doing something just a little more processor-intensive (read on). NOT cheap however so you might want to check total cost including postage.

WiCDAbout the only thing I really did not like about the Debian setup for the T3 was wpa_gui which not only looks naff – but also fails to report the status of WIFI.  It would connect no problem but then still say “connect” – which is a worry.

Now, as it happens I have one of the FriendlyArm M1s again running Debian and that has wiCD Net work manager which does work. So I figured, in for a penny, in for a pound.

sudo apt-get install wicd

I had to tell it about the connection at first as it didn’t have my wifi details stored… and then

sudo apt-get remove wpagui

Problem solved. Now – getting the GPIO to work – it’s not an H3 so I can’t use WiringOp…. out of ideas on that one for now.

One issue with the T3 – is the eMMC itself. All of the above was done using eMMC and in an attempt to copy that to SD, I blew the lot. Why was I doing that? Because I can find no simple way to back up and restore the internal eMMC. I can't actually see much use for 8GB of EMMC especially as it is a pain to back up.

I spent ages getting onto the Baidu site trying to get an SD version of the software as the Google Drive link on FriendlyArm’s website just would not work. I don’t know if you know but if you don’t read Chinese – getting a Baidu account can be a treat. Anyway I finally got one.

Update: I contacted FriendlyArm at least twice about this as their Google Drive link does not work – I don’t know what BAIDU is like inside China but it is ATROCIOUS outside of it. This is my third attempt took well over an hour… I would normally get such a small file in a matter of minutes at most.

Baidu SLOW

When I eventually got the file – I realised I could get it to run – but I could not expand it – I tried various approaches including with support from FriendlyArm and the SD simple would not expand – I wanted to use an 64GB SD yet could access only a tiny amount of available storage – which seems awfully silly.  With Android up and running the first thing I tried was a media player – but because there is no information on the infrared remote control, I thought I’d try WIFI control by my phone – but THAT requires root access and the Android provided is not rooted – worse – Kingroot simply will not root it.

Meantime, FriendlyArm sent me some information on expanding the board - info that they had previously put out on the web and it simple would not work - I've now checked and there is nothing out there on this - HOWEVER - their solution works - they just missed out some important info.

When you blow their image onto SD - BEFORE you start playing with Android AT ALL, stick the SD into a Linux PC or a Raspberry Pi or similar (or a Debian machine on one of their boards) - and do the following exactly... firstly check that SDA is available (/dev/) and if not - maybe it is SDB??

So to recap, flash the Android SD - put it straight into a Linux computer - and run the commands below - do not "try it out" in the T3 first or you will fail.

Replacing SDA with SDB etc if  necessary (I've done several installations and not had to change this)...

sudo parted /dev/sda unit % resizepart 4 100% resizepart 7 100% unit MB print
sudo resize2fs -f /dev/sda

Now This isn't EXACTLY what Friendlyarm said in their instructions - but then their exact instruction didn't work - this does. Once done, take the SD out - stick it in your T3, hold the BOOT button, turn the power on and after a few seconds release the BOOT button. Might take a minute or so for Android to come up - originally I was getting a 4GB Android which is about as much use as an ashtray on a motorbike - now  I have one set up with 32Gb and another with 64GB of internal memory - no problem. All of this this will work in a NanoPC T2 but overall I found that to be sluggish.

From there I've put KODI and several other programs in there and it all works very well - the hardware Ethernet being a boon if you're streaming TV shows etc. and the video runs smoothly.

Now all I have to do is figure out how to get the board to boot into Android on SD without having to press the button... I did try just holding the button down and that works so worst case I could see a link coming on.

Update November 29th 2016:  As you’ll see elsewhere I’ve been playing with the Nanopi M3 – a great little board with a nice heatsink and fan that makes for a good media centre… the only issue is – the noise of the fan. It is something one can deal with but it was enough to have me do one last test of the T3. There is now an image for the T3 that will boot up and let you have your choice in a menu of Ubuntu, Debian or Android 5.1.1  - now, I have commented in the blog that I am not stunningly impressed by either Debian or Ubuntu on these devices – at least not the FriendlyArm version and I really would like to see an up to date Android available – however – I thought I’d try this all in one SD image – which lets you easily blow code to the EMMC.

Well I have to say – M3 on SD – or T3 on EMMC – the results are quite clear – the T3 is FASTER.  Running Kodi I noticed that videos play smoothly on the M3 until you pop up the menus – and running the video with all that guff overlaid onto it makes for a very SLIGHTLY jerky movement – but enough to notice it. Not so on the T3 which runs, to use a local phrase, as smooth as a baby’s bottom!  Also Android is one hell of a lot easier to tackle for overscan and resolution changes than the other options and I was soon able to turn the mighty T3 into quiet a reasonable stick-on-the-back-of-the-TV media centre and I am more than happy with the results!

Facebooktwittergoogle_pluspinterestlinkedin

Arduino 16 bit PWM Revelation

Here is a piece of code I found – quite old now.  As most Arduino users will know, the PWM on the 328 chip is a bit… naff at only 8 bits. When attached to LEDS, at the low end, each step is painfully obvious – even value 1 is visible immediately – not then much use for smooth lighting!

However I discovered this..

void setupPWM16() {
    DDRB |= _BV(PB1) | _BV(PB2);        /* set pins as outputs */
    TCCR1A = _BV(COM1A1) | _BV(COM1B1)  /* non-inverting PWM */
        | _BV(WGM11);                   /* mode 14: fast PWM, TOP=ICR1 */
    TCCR1B = _BV(WGM13) | _BV(WGM12)
        | _BV(CS10);                    /* no prescaling */
    ICR1 = 0xffff;                      /* TOP counter value */
}
/* 16-bit version of analogWrite(). Works only on pins 9 and 10. */
void analogWrite16(uint8_t pin, uint16_t val)
{
    switch (pin) {
        case  9: OCR1A = val; break;
        case 10: OCR1B = val; break;
    }
}

That lovely piece of code lets you put 16-bit PWM on ports 9 and 10 at the expense of TIMER 1 – MARVELOUS unless you want to do RGB lighting – as there are only two.

So I kept on looking. The 1284P chip – compatible but more powerful than the 328, has an extra 16 bit timer (ignore the blogs that say it does not – the guys are reading out of date info).  It occurred to me that you should be able to use Timer 3 to get an extra 2 channels at 16 bits – wouldn’t that be marvellous.

Sadly there’s a problem – lack of info on Timer 3 meant that even after guessing the changes needed to that setup (ports 6 and 7 not 9 and 10) I managed to get the new PWM on port 7 – but not 6.  And worse – they’ve gone and stuck this in the middle of the pins for SCK, MOSI and MISO so you can’t do both at the same time. Ah well. I simply changed all references to timer 1 to timer 3 to get port 7 working but that didn’t seem to help port 6.

So I was wondering – the 2560 boards – they have even MORE timers. Has anyone taken this basic code and managed to get more 16-bit PWM timers on the the MEGA2560 boards?

Facebooktwittergoogle_pluspinterestlinkedin

BME280 Box of Tricks

bme280I’ve just wasted more time than I care to think, trying to get a BME280 driver to work – finally done it by adapting some work from this fellow (Cosmin Plasoianu) who’s code is good but was out of date for the current SDK and also referred to another chip as so many bits of code do – the BMP280.

So what’s the difference? Well, the BMP280 is a modern temperature and pressure chip – but it does NOT do what the BME280 does – and that is humidity. In other words it can form a replacement for the DHT22 as long as you don’t mind using another wire (i2c). It responds quickly and is relatively accurate. The BME280 is also on a different I2c address to the BMP280.  Anyway – all SORTED.

It is not cheap at nearly £4 but adding in pressure lets you do all sorts of weather-predicting stuff!  As usual I limit accuracy to the nearest degrees C or percentage humidity because while seeing decimal points looks good  - the ultimate accuracy does not warrant it.

I’ve updated the manual {temp_type:3}  - and this uses i2c. The new command assuming GPIO4 and 5 are used for I2c and assuming there are pull-ups in use  - this  fills in the variables temperature, pressure and humidity which can be accessed as {temperature?} {pressure} and {humidity} as normal and are also generated automatically – see manual.

One more success for Home Control 2016.

humidity

Facebooktwittergoogle_pluspinterestlinkedin

NanoPi M2

NanoPi M2More from FriendlyArm – this time the NanoPi M2.  I’ve had this board running both Debian and Android – but first – a little about the boards. Like the M1 these are small – around 65mm by 60mm so much smaller than Raspberry Pi. They are also cheaper than the Pi but but this time more powerful than the M1 and most likely the Pi, also.

Unlike the M1, the board comes with a connector for FriendlyArm’s touch-LCD display and also unlike the M1 which comes with an awful Android with no Play Store, this one is a 5.11 version with full playstore.  I’ve tried it with BBC video and it runs flat out M1so I have no doubt this would make a media centre for anyone interested. Indeed I’m waiting for a wireless keyboard/mouse arrangement turning up and one of these might just end up as a media centre.

The board has 2 USBs connectors and it has 0.1” connectors on board for a further two. It has up to 1GBPS Ethernet connection, audio jack, microphone, camera connector, standard HDMI out and a microSD slot on the underside.  Mine came with 1GB RAM. There is also a header for a serial console.

The processor is a Samsung S5P4418 quad core Cortex A9 running between 400Mhz and 1.4Ghz. There is also a Mali GPU. I’ve not yet done speed tests but I’d expect this to give the Pi a run for it’s money – again – how they compare depends on postal charges in your area.

My next step will be to install my usual software script on this board in Debian and we’ll see then how easy or otherwise it is to get port and serial access. Keep looking in.

Facebooktwittergoogle_pluspinterestlinkedin

Coming up..

Coming up in the next couple of weeks – the FriendlyArm M2 – how does it compare with the M1? ESP8285 – first look…. and the new Itead plug-in-the-wall WIFI switch.

Meanwhile I’ve decided that if I keep trying to figure out why my FTDI won’t work properly in a Raspberry Pi I may end up injuring myself so I’ve a couple of dissimilar models coming to try those.

Facebooktwittergoogle_pluspinterestlinkedin

Anonymous

Just a quick note folks for anyone new looking in.  I've had some emails in recently which were generally just links with no explanation - and usually the word anonymous or similar was in the email address.  For the sake of clarity, I have to approve all new incoming emails (once approved, folk can of course post freely). If I see emails like this I'm afraid I simply bin them as spam - it would not be fair to readers who bother to put in legitimate information to send them off on a wild goose-chase.

So of course this blog welcomes all manner of feedback, please use a legit email and if you are sending links let us know in the post what they are about.

Thanks!

Pete.

Facebooktwittergoogle_pluspinterestlinkedin

Raspberry Pi Backups

Backups the easy way

One of my biggest issues with the Pi has always been – backups.  Using a PC to backup a 16GB SD is a pain and of course necessitates turning the Pi off to remove the SD. Well, now there’s a better way.

A slightly less painful way than backing up the whole SD with a PC is to use BerryBoot which can do a good job of running Raspbian and at power-up giving you the option to store a compressed version of the SD to USB memory.

It was with sadness then that I updated Raspbian today to the latest version.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install piclone geany usb-modeswitch
sudo apt-get install python-pigpio python3-pigpio

Nice theory but in practice, on reboot, I ended up with an utterly dead board – something to do with the update and BerryBoot.  I’ve reported this to the BerryBoot author.

But here’s the thing – the latest version of Raspbian Jessie now for the first time includes a live backup facility. Once you have this you’ll wonder why it was not always this way – especially if, like me you’re not a Linux fanatic.

It does not stop there however. Not only will this new utility copy from live to SD (I’ve yet to figure out how to run the SD copier from the command line but it runs from menu – accessories – SD card copier  without issue) but also – and I’m quite excited about this – you don’t need the same size SD – which means expansion or reduction is now a snap – thank heavens for that.

So in order to test this new backup facility – I grabbed the latest Raspbian (not the NOOB version) and blew it onto a16GB SD with Win32DiskManager as usual. I started up the Pi3 and put another identical SD into a convertor and stuck the USB convertor into a spare USB slot. I ran the backup, powered down, swapped SDs over and rebooted – no problem at all. Fantastic.

For my second test – I ran my script on the Raspberry Pi 3 so it was fully up to date with all of my tools – Apache, PHP, Mosquito, Node-Red, SQLite etc. – on a 16GB card. I then made a  backup the same way as above to an 8GB card…  the transfer took place while writing this blog – all in around 15 minutes.

I powered off the Pi3, put in the 8GB card and powered up. IT WORKED!!!!

With that success behind me I decided to get brave. I took the new card and put it into a Raspberry Pi 2 – surely this could not possibly work? IT WORKED!!!!

For some this may be nothing – for others a life-saver – so now it is easy – without even powering down to make copies of a working system – even on different size cards and it would seem interchangeable between Pi2 and Pi3.  Other Pi-like manufacturers take note!! Now I can be WAY more adventurous as it is so easy to make backups.

PigPio

connectionsWhile I was on I thought I’d try the new pigpio GPIO interface.

Firstly I started up the pigpio daemon – at this point being new to me I have no idea how to make this run at power up – nor do I know if there is a reason you should NOT run this at power-up.

sudo pigpiod

Bear in mind that everything was originally set up on a Pi3 – but by this time I was running the SD on a Pi2, not the Pi3.  I like doing things interactively when I’m learning so I simply typed python <enter>

I was greeted with >>

I fastened a LED/resistor combo (I always keep a few ready with female connectors on them for testing)  between connector pin 6 (ground) and 12 (GPIO18).

>> import pigpio

>> mypi=piggpio.pi()

>> mypi.write(18,1)

And it worked – the light came on and off when I used the same command with 0 as the last parameter. I’m dying to try the other more complex commands in a Python program. indeed today everything just seems to be working – the sun is shining, my gadgets are working – what more could one want. I have one duff Electrodragon (more on that later) but apart from that…

Facebooktwittergoogle_pluspinterestlinkedin

Special UK quality

Is it just me or do others find this kind of thing annoying? I thought it might be a good idea to get a PCF8574T I2C I/O expander as a little add-on to the home control system, so you could plug it into, say GPIO4 and GPIO5, losing 2 outputs – and gain 8 – net gain 6 outputs…

So off I went to Ebay – and clearly being a Brit I’d like to support British companies.  I wonder what extra value the UK version would bring? I’m currently in Spain as many of you know.. aside from customs (which would not apply at this price) and tracking…

Chinese version (and not untypical pricing).

Chinese PCF8574T

UK version (not seeing any extra gold-plating).

UK PCF8574T

Not surprisingly I’ll be ordering from China – keep eyes peeled in a couple of weeks or so for blog updates on this.

Facebooktwittergoogle_pluspinterestlinkedin

PWM Woes

 

Just in case anyone is having issues with the ESP8266 SDK and PWM. Problem now “solved” but you might find this interesting.

For many months now I’ve been using the PWM on the ESP8266 successfully, so much so that I’ve not tested it and just recently I’ve noticed it no longer works. Specifically, the PWM startup routine forces my ESP8266s to reboot with a watchdog timeout.

So first things first, the SDK manual appears to STILL be incorrect. It states in version 1.53 (ESP8266 SDK API guide) in page 178 that the DUTY parameter is pointer to an 8 bit array.

Yet the header and routines elsewhere require 32 bit values for the array. I’ve always ignored this.

#define PWM_1_OUT_IO_MUX PERIPHS_IO_MUX_MTDO_U
#define PWM_1_OUT_IO_NUM 15
#define PWM_1_OUT_IO_FUNC FUNC_GPIO15

#define PWM_3_OUT_IO_MUX PERIPHS_IO_MUX_GPIO4_U
#define PWM_3_OUT_IO_NUM 4
#define PWM_3_OUT_IO_FUNC FUNC_GPIO4

#define PWM_4_OUT_IO_MUX PERIPHS_IO_MUX_GPIO5_U
#define PWM_4_OUT_IO_NUM 5
#define PWM_4_OUT_IO_FUNC FUNC_GPIO5

uint32 duty[] = {0, 0, 0};
uint32 freq = 1000;
static uint8 donepwm = 0;

uint32 io_info[][3] = {
  {PWM_1_OUT_IO_MUX, PWM_1_OUT_IO_FUNC, PWM_1_OUT_IO_NUM},
  {PWM_3_OUT_IO_MUX, PWM_3_OUT_IO_FUNC, PWM_3_OUT_IO_NUM},
  {PWM_4_OUT_IO_MUX, PWM_4_OUT_IO_FUNC, PWM_4_OUT_IO_NUM}
};

So with these definitions I call….

if (donepwm == 0) {
   pwm_init(freq, duty, 3, io_info);
   donepwm = 1;
}

 

You should call the setup once only.. hence the wrapper using “donepwm”. This has always worked and yet now, no matter what I do, this crashes the processor – usually a few seconds after it has been called.

Result..

ets Jan  8 2013,rst cause:4, boot mode:(1,0)

wdt reset

This used to work – now it causes the WDT.

The example in the manual..

Example: uint32 io_info[][3] =  {{PWM_0_OUT_IO_MUX,PWM_0_OUT_IO_FUNC,PWM_0_OUT_IO_NUM},          {PWM_1_OUT_IO_MUX,PWM_1_OUT_IO_FUNC,PWM_1_OUT_IO_NUM}, {PWM_2_OUT_IO_MUX,PWM_2_OUT_IO_FUNC,PWM_2_OUT_IO_NUM}};

pwm_init(light_param.pwm_period, light_param.pwm_duty, 3, io_info);

HERE is a  “fix”…

http://www.esp8266.com/viewtopic.php?f=6&t=4675&p=46060#p46060

I amended the rom0.ld file and sure enough – fixed…

But that means there’s an issue somewhere –  and that manual needs fixing  - I hope Espressif are looking in.

Facebooktwittergoogle_pluspinterestlinkedin